Issue #15745 has been updated by zverok (Victor Shepelev).


My reasoning is semi-open ranges are valuable feature, and by `inspect` we should suggest to users their "naturalness", not "it is just a quick hack, look". 
Explicit rendering of `nil` is *underlining* some kind of "hackiness" ("it is just a syntactic sugar for `1..nil` underneath"). 
I believe it is an important new language feature, and it should be represented adequately. 
`1..nil`/`nil..1` is not adequate, because it is hard to read: "range from 1 to nothing"? (it doesn't read as "range without end", which it is).

So I'd say that:
1. `p (1..) # => (1..)`, and that's the only adequate representation
2. `p (..1) # => (..1)`, and that's the only adequate representation
3. How `nil..nil` is represented is not THAT important, because it is the rarest and less useful case; I don't think even `(..)` is that bad. It looks kinda weird, but it still is what it is: "range (designated  by `..`) with neither end nor beginning". 

The point is, there could be a discussion about (3), and it is only marginally important; but not about (1) and (2).
In this line of reasoning, "Make `(..1)` looking weird for consistency with `(nil..nil)`" is less than desirable.

----------------------------------------
Bug #15745: There is no symmetry in the beginless range and the endless range using `Range#inspect`
https://bugs.ruby-lang.org/issues/15745#change-77862

* Author: koic (Koichi ITO)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-04-03 trunk 67423) [x86_64-darwin17]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
The following commit introduces beginless range.
https://github.com/ruby/ruby/commit/95f7992b89efd35de6b28ac095c4d3477019c583

```
% ruby -v
ruby 2.7.0dev (2019-04-03 trunk 67423) [x86_64-darwin17]
```

There is no symmetry with endless range when using `Range#inspect` method.

```
(1..).inspect # => "1.."
(..5).inspect # => "nil..5"
```

How about unifying whether it represents `nil`?




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>