From: duerst@... Date: 2018-06-05T06:30:33+00:00 Subject: [ruby-core:87411] [Ruby trunk Bug#14823] Endless Range Excluding End Issue #14823 has been updated by duerst (Martin D��rst). mame (Yusuke Endoh) wrote: > * `(1..)` is semantically weird because it does not include the infinity. `(1..)` includes infinity. It's (1...) that doesn't include infinity. ```ruby (1..5).include? 5 #=> true (1...5).include? 5 #=> false ``` 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: ```ruby (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 ```ruby (1...).include? Float::INFINITY ``` and the answer we get currently isn't consistent with Mathematics. ---------------------------------------- Bug #14823: Endless Range Excluding End https://bugs.ruby-lang.org/issues/14823#change-72396 * Author: jeremyevans0 (Jeremy Evans) * Status: Feedback * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-openbsd] * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- Does it make sense for an endless range to exclude the end? It is currently supported, but the semantics are questionable. ~~~ (1..) # => 1.. (1...) # => 1... (1...) == (1..) # => false ~~~ I think it may be better to only allow `..` for endless ranges, and not allow `...`. I think the use of `...` with an endless range should be a SyntaxError. -- https://bugs.ruby-lang.org/ Unsubscribe: