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(x..-1,0...x)
*grin* Try doing that as concisely without "..."
-- MarkusQ
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(x..-1,0...x)
*grin* Try doing that as concisely without "..."
-- MarkusQ
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(x..-1,0...x)
*grin* Try doing that as concisely without "..."
-- MarkusQ
deck = deck.values(x..-1,0..x-1)
Zach
Markus ha scritto:
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(x..-1,0...x)
*grin* Try doing that as concisely without "..."
with my syntax:
x..,0..x-1
one key less ![]()
(though now I see a reason for excluding ranges)
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
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(x..-1,0...x)
>
>*grin* Try doing that as concisely without "..."
>
>-- MarkusQ
>
>
deck = deck.values(x..-1,0..x-1)
> Markus wrote:
> >deck = deck.values(x..-1,0...x)
> deck = deck.values(x..-1,0..x-1)
Oops. Should be "values_at" in both cases. "values" is a site-local
synonym.
-- MarkusQ
Exactly.
(3..5-1).include? 4.4 #=> false
(3...5).include? 4.4 #=> true
KB
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(x..-1,0...x)
>
>*grin* Try doing that as concisely without "..."
>
>-- MarkusQ
>
>
deck = deck.values(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
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
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-1Exactly.
(3..5-1).include? 4.4 #=> false
(3...5).include? 4.4 #=> true