Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The first example is an actual example of how removing ifs can reduce complexity, but the last few seem misguided. It is no easier to test `collection.each {|item| result << item if item.condition? }` than `collections.select(&:condition)`; they are all but equivalent. The exception handling example doesn't actually show the benefit of not using ifs, it shows the benefits of using exceptions over return values. Setting up default values via || is also a nice trick, but it hardly makes a macro difference.

Also, "# I slept during functional classes"? I don't know ruby, but the `each` method seems to be just a variant of map, which is a pretty fundamental functional construct.



each is basically an entirely non-functional variant of map if functional is defined as no side affects.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: