I agree with shevegen. In case one of the two is to be removed, it is 1.. that should be removed, not the other way around.
My understanding is that the .. notation corresponds to the mathematical notation ] (end of closed interval), whereas ... corresponds to ) (end of open interval). And in mathematics, there is such thing as
For enumerators, it doesn't matter whether the end of an infinite range is included or not, because we'll never reach it. But for other operations, such as include?, it matters.
Currently, we have:
(1..).include?Float::INFINITY#=> true(1...).include?Float::INFINITY#=> true #### should be false?!
mame (Yusuke Endoh) wrote:
Also, ary[1..] looks better than ary[1...].
All the valid indices of the array are finite, so there's no difference here. Just having ary[1..] only would be fine.
sawa (Tsuyoshi Sawada) wrote (rewritten to use Unicode characters):
I agree with shevegen. In case one of the two is to be removed, it is 1.. that should be removed, not the other way around.
My understanding is that the .. notation corresponds to the mathematical notation ] (end of closed interval), whereas ... corresponds to ) (end of open interval). And in mathematics, there is such thing as
[1, ∞)
but there is no such thing as
[1, ∞]
It is true that this is the convention followed in Mathematics. But in Ruby, we can easily write
(1...).include?Float::INFINITY
and the answer we get currently isn't consistent with Mathematics.
It is true that this is the convention followed in Mathematics.
It actually depends which mathematics we are talking about. Transfinite mathematics deal with different infinities. Check in particular the "surreal numbers".
Still, for Ruby, I agree that it would be best to have something simple.
I would accept (x..) and automagically change it to (x...).
(42..) # => (42...)
(42..) == (42...) # => true
I particularly like the fact that "42..." is a nice notation for "42 and up".