3 ms·
Overly clever or confusing to you, idiomatic to others (and vice versa).
by jpr 16y ago
Overly clever or confusing to you, idiomatic to others (and vice versa).
- axod 16y agoThe former isn't guessable unless you know special modifier characters. It's also error prone if you typo a single character. The latter is readable.
- djacobs 16y agoThat's true, but the modifier character* (not more than one) is consistent: & says "take the named method, call to_proc on it, and pass it in as a block". Since many methods allow blocks to be passed to them, this kind of code is useful and well-understood, I think. I want to note that the &:even? idiom is only used in the simplest cases.
- chc 16y agoYou're contrasting "not guessable" with "readable." The behavior of Ruby's `||` is not guessable for a lot of people but it's still quite readable if you know the language.