Markus
10/2/2004 3:12:00 PM
On Sat, 2004-10-02 at 04:05, Kristof Bastiaensen wrote:
> On Sat, 02 Oct 2004 07:51:03 +0900, markus wrote:
>
> > On Sat, 2 Oct 2004, Zach Dennis wrote:
> >
> >> Markus wrote:
> >>
> >> >Here's a simple example of where ... is very nice to have. You want to
> >> >cut a deck and card x, so that x is on the top after the cut:
> >> >
> >> >deck = deck.values_at(x..-1,0...x)
> >> >
> >> >*grin* Try doing that as concisely without "..."
> >> >
> >> >-- MarkusQ
> >> >
> >> >
> >> deck = deck.values_at(x..-1,0..x-1)
> >>
> >>
> > Nope. Sorry. Try it with:
> >
> > deck = (1..52).to_a
> > x = deck.index(1)
> >
> > (or just a deck from 1..10 if you prefer) and then try again.
> >
> > -- MarkusQ
> >
> > P.S. I repeat, a...b is NOT a synonym for a..b-1
>
> Exactly.
>
> (3..5-1).include? 4.4 #=> false
> (3...5).include? 4.4 #=> true
Agreed. But that's not the only difference. The idiom above
relies on another difference to function properly. I'm surprised no one
has jumped on it yet. (Especially after all the talk about "..." not
being useful. *evil grin* You'd think one of them could show me how
unneeded it is in this context).
-- MarkusQ