Actions
Feature #20483
openMore intuitive initialisation of null Range
Feature #20483:
More intuitive initialisation of null Range
Status:
Open
Assignee:
-
Target version:
-
Description
Hi all 👋🏻
I've come across cases where I want a method to return a Range. In some cases, the Range should be empty.
I see from the documentation, that it's possible to initialise a null Range by passing in values where a is greater than b Range.new(1, -1)
.
I find this particular notation to be unclear, and likely to be discouraged by my team because it's unclear.
I'm opening this discussion to see if there's any interest in support for a simpler notation for null (empty) Ranges. Something like:
r = Range.new(nil) # notation not currently supported
r.size # => 0
r.max # => nil
r.min # => nil
r.each { puts "This is never called" }
Actions