[ruby-core:109770] [Ruby master Bug#18983] Range#size for beginless Range is not nil.
From:
"masasakano (Masa Sakano)" <noreply@...>
Date:
2022-08-29 14:10:12 UTC
List:
ruby-core #109770
Issue #18983 has been reported by masasakano (Masa Sakano). ---------------------------------------- Bug #18983: Range#size for beginless Range is not nil. https://bugs.ruby-lang.org/issues/18983 * 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) -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>