From: Julian Leviston Date: 2008-04-02T11:17:08+09:00 Subject: Re: What is Ruby's biggest strength ? Er.... I agree with you. LoL. Strange response! Julian. On 28/03/2008, at 1:19 PM, Alex Fenton wrote: > Julian Leviston wrote: >> So, you think this: >> #include >> for(count = 1; count <= 200; count++) { >> printf("%d ", count * 300); >> } >> is less ugly than this: >> puts (1..100).map{|num| num * 300}.join(" ") >> are you serious? >> Even if you spell all the ruby out fully, then you end up with >> less code, and it's much nicer looking and easier to understand, >> even to non-programmers: >> range = (1..100) >> multiplied_numbers = range.map{|num| num * 300} >> string_to_output = multiplied_numbers.join(" ") >> puts string_to_output > > It's a trite example, and I agree that both your implementations are > ugly. With any language, the unfamiliar will tend to write clumsy > code that obscures their intention. I get the impression you're not > interested in being persuaded, but: > > 1.upto(100) do | i | > printf "%d ", i * 300 > end > > >> But even if you think the syntax is >>> clean, ruby is all about cramming 4 or 5 function calls into one >>> line >>> and sprinkling some regex's in for spice, which is creates an >>> indecipherable mess. > > You're missing the point that iterators - one of the commonest tasks > - are easier, clearer and terser to write in Ruby than your C-esque > for(...) loop or even a Perl "foreach @array" or "each %hash". > > The fact that some people choose to use all the space which they > saved in not writing tedious loop verbiage to cram multiple method > calls into a line is a matter for their taste, or lack of it. I > think you'd be hard-pushed to find examples in, for example, the > ruby standard libraries. > > a > >