Actions
Bug #18983
closedRange#size for beginless Range is not nil.
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]
Description
Range#size
should, according to Official docs,
Returns the count of elements in self if both begin and end values are numeric; otherwise, returns nil
but it doesn't with beginless non-Numeric Ranges (in Ruby-3.1.2 or earlier).
(..?a).size # => Infinity
(nil..nil).size # => Infinity
whereas it certainly does with endless Ranges
(?a..).size # => nil
Files
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0