Re: "Readability" inflation
- From: Brian Schröder <ruby.brian@xxxxxxxxx>
- Date: Sun, 30 Oct 2005 03:02:51 +0900
On 29/10/05, Dominik Bathon <dbatml@xxxxxx> wrote:
> On Sat, 29 Oct 2005 17:52:05 +0200, Trans <transfire@xxxxxxxxx> 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/
.
- Follow-Ups:
- Re: "Readability" inflation
- From: Dominik Bathon
- Re: "Readability" inflation
- From: Daniel Schierbeck
- Re: "Readability" inflation
- From: David A. Black
- Re: "Readability" inflation
- References:
- Re: "Readability" inflation
- From: Martin DeMello
- Re: "Readability" inflation
- From: Dominik Bathon
- Re: "Readability" inflation
- Prev by Date: Re: [ANN] gdiff / gpatch 0.0.1 released
- Next by Date: Re: The "perfect" ORM?
- Previous by thread: Re: "Readability" inflation
- Next by thread: Re: "Readability" inflation
- Index(es):
Relevant Pages
|