DEV Community

Discussion on: I did it again.

Collapse
 
chrisvasqm profile image
Christian Vasquez • Edited

I really like doing this, but sometimes, when looking at the code really quick, in those languages that use the ! operator, I've found myself doing functions like isNotEmpty() so that I don't overlook the ! by mistake.

Kotlin's standard library has methods like isNotBlank() and isNotEmpty() as part of the String class that showcase this.

Collapse
 
joelnet profile image
JavaScript Joel • Edited

Ramda has a function called complement that can help you build these functions.

import complement from 'ramda/src/complement'

const isEven = num => num % 2 === 0
const isNotEven = complement(isEven)