Hacker News new | ask | show | jobs
by tptacek 5193 days ago
Especially because some bare method calls will produce syntax errors ('class' being the obvious example).

I think there's no good rule of thumb to be had here; use whichever style makes the code clearer.

1 comments

That's exactly the rule of thumb that makes for good Ruby: use whatever style makes the code clearest. Over the last ten years, my Ruby has evolved as I've come to understand this (and it's affected the code I write in every other programming language I know, including bash scripts).

At times, this means I have to skip a one-liner because it's not as clear as expanding it out; at other times, it means using a one-liner because it's clearer than an expanded form. Sometimes it means using #length on a String or Array, sometimes it means using #size. They do the same thing (much to the annoyance of some folks), but the fact that both work means I can think about how my code reads.