From: "matz (Yukihiro Matsumoto)" Date: 2022-10-20T04:32:42+00:00 Subject: [ruby-core:110428] [Ruby master Bug#18983] Range#size for beginless Range is not nil. Issue #18983 has been updated by matz (Yukihiro Matsumoto). 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. Matz. ---------------------------------------- Bug #18983: Range#size for beginless Range is not nil. https://bugs.ruby-lang.org/issues/18983#change-99738 * Author: masasakano (Masa Sakano) * Status: Open * Priority: Normal * ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- `Range#size` should, according to [Official docs](https://ruby-doc.org/core-3.1.2/Range.html#method-i-size), > 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). ```ruby (..?a).size # => Infinity (nil..nil).size # => Infinity ``` whereas it certainly does with endless Ranges ```ruby (?a..).size # => nil ``` ---Files-------------------------------- bug-20220829-beginless_range.rb (1.24 KB) 6378.patch (1.37 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: