Range#size for beginless Range is not nil.
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
Updated by jeremyevans0 (Jeremy Evans) 3 months ago
Returning Infinity for numeric ranges bounded in either direction is expected (there are tests explicitly for it).
It does seem inconsistent that
(..object).size returns Infinity and
(object..).size returns nil for non-numeric objects. I think returning nil in both cases makes sense.
Updated by matz (Yukihiro Matsumoto) about 2 months ago
I agree with inconsistency; if edges were numeric, return the count (or Infinity), otherwise it should return nil.
nil .. nil can be considered as numeric-range both edge omitted, but at the moment I feel it should return nil as well.
Let us experiment how it works.