3 ms·
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
by halostatue 15y ago
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.