re: 5 Programming Patterns I Like VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Nice post! Re #1: Rubocop calls them "guard clauses" and I tend to prefer that style as well. But if there are only two branches, I sometimes pre...
 

Oh yeah, in case you haven't seen it in action, you might be interested to know that a side-effect-free series of map calls can be refactored similar to your #3. map distributes across function composition, so

map(g, map(f, coll)) == map(compose(g, f), coll)

The latter form only walks the collection once, obviously. You can compose the functions manually or borrow compose from a library like Ramda.

code of conduct - report abuse