## Bug #14823

closed### Endless Range Excluding End

**Description**

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.

#### Updated by shevegen (Robert A. Heiler) about 3 years ago

This boggles my mind.

I thought an endless range means infinity, or "open ended". Can we reach the point

before infinity, or after infinity - or "endlessity"?

This here also tampers with my mind:

(1...) == (1..)

But in a wicked way ... adding one more '.' should make it be more than just

infinity now, should it not. :)

I think the use of ... with an endless range should be a SyntaxError.

I agree, if only for keeping my sanity.

#### Updated by mame (Yusuke Endoh) about 3 years ago

**Status**changed from*Open*to*Feedback*

Thank you for the comment.

This argument is very subtle. Some (mathematical) people says that we should have `(1...)`

because of two reasons:

`...`

is preferably used to port Python code to Ruby because Python's`::`

is literally corresponded to Ruby's`...`

.`(1..)`

is semantically weird because it does not include the infinity.

In other aspect, I like `(1..)`

for casual use because it is shorter than `(1...)`

. Also, `ary[1..]`

looks better than `ary[1...]`

.

So, currently, we have both. If you have any practical issue caused by having both, let me know.

#### Updated by sawa (Tsuyoshi Sawada) about 3 years ago

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, \infty)$

but there is no such thing as

$[1, \infty]$

#### Updated by duerst (Martin Dürst) about 3 years ago

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.

```
(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:

```
(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.

#### Updated by marcandre (Marc-Andre Lafortune) about 3 years ago

duerst (Martin Dürst) wrote:

mame (Yusuke Endoh) wrote:

but there is no such thing as

[1, ∞]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".

#### Updated by jeremyevans0 (Jeremy Evans) 11 months ago

**Status**changed from*Feedback*to*Closed*