Why Ruby?

Ary Borenszweig ary at esperanto.org.ar
Mon Dec 13 10:19:26 PST 2010


It's not to be used everywhere, but in many cases it makes the code more readable.
Compare

str = some_string
if (str.start_with?('foo')) str = str[3 .. -1]
str = str.downcase

with this:

str = some_string
str = str[3 .. -1] if (str.start_with?('foo'))
str = str.downcase

See? You can see the processing on the left and on the right the conditions on
which that processing is applied. Or sometimes you have

return if some_condition_is_met

And sometimes in English (or any other language) you think like that. "Ah, I
should remove this from the string if some condition is met".

It looked very strange and sometimes wrong to me at first...


More information about the Digitalmars-d mailing list