From: "mame (Yusuke Endoh)" Date: 2022-10-21T04:41:06+00:00 Subject: [ruby-core:110454] [Ruby master Bug#18983] Range#size for beginless Range is not nil. Issue #18983 has been updated by mame (Yusuke Endoh). https://github.com/ruby/ruby/pull/6604 ---------------------------------------- Bug #18983: Range#size for beginless Range is not nil. https://bugs.ruby-lang.org/issues/18983#change-99770 * 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: