Skip to content
loading...
re: Tip to prevent this from happening in the future: Extract your if logic into its own function. Instead of: if (num % 2 === 0) {} Write: ...
 

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.

 

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)
code of conduct - report abuse