From: Daniel Schierbeck Date: 2005-10-30T03:22:04+09:00 Subject: Re: "Readability" inflation Brian Schr�der wrote: > On 29/10/05, Dominik Bathon wrote: > >>On Sat, 29 Oct 2005 17:52:05 +0200, Trans wrote: >> >> >>>Brian Schr�der wrote: >>> >>>>If you are so bold, I have to chime in again to say that >>>> >>>> ary.sort_by :meth >>>> >>>>reads a lot better than >>>> >>>> ary.sort_by.meth >>>> >>>>because we don't do method chaining here. >>>> >>>>Sorry, could not resist. ;-) >>> >>>Ahhhhh... but can you do: >>> >>> ary.sort_by.meth(foo, bar, wack!) >> >>So, what we really need is the implicit block variable, because it can do >>all that ;-) >> >>ary.sort_by { it.meth } >> >>ary.sort_by { it.meth(foo, bar, wack!) } >> >>and even: >> >>ary.sort_by { some_hash[it] } >> >> >>Dominik >> > > > What is so bad about > > ary.sort_by { | it | it.meth(foo, bar, wack!) } > > Then you can even make your sourcecode readable by putting information > into the it > > playlist.sort_by { | track | track.meth(foo, bar, wack!) } > instead of > playlist.sort_by { it.meth(foo, bar, wack!) } > > where it is unclear what the it is. > > regards, > > Brian I agree. `it' would seem to refer to the playlist itself, not the playlist item. This would be good too: playlist.sort_by :track_length Cheers, Daniel