Added by ted (Ted Johansson) over 3 years ago.
Updated over 3 years ago.
Range already responds to #size. It would be nice if it also responded to predicate #empty? :-)
Would be nice.
Note that Range#size currently returns nil for ranges of string, so it's not clear what empty? would return for ranges of strings.
Range mixes in Enumerable so you can use #none?.
('a'..'b').none? #=> false
('b'..'a').none? #=> true
I think the semantics between ".none?" is not the same as ".empty?". At
the least the latter appears to be more explicit to me.
But it's also not that important to me personally, I am fine either way. :-)
Also available in: Atom