From: "Brian Schröder" Date: 2005-10-30T03:02:51+09:00 Subject: Re: "Readability" inflation 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 -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/