From: "thiagofm (Thiago Massa)" Date: 2022-09-14T22:01:29+00:00 Subject: [ruby-core:109895] [Ruby master Bug#18983] Range#size for beginless Range is not nil. Issue #18983 has been updated by thiagofm (Thiago Massa). File 6378.patch added I've fixed the bug on the attached patch. It's my first time contributing to Ruby, so please let me know if anything is missing. I'm following the contribution guide on https://ruby-doc.org/core-3.1.1/doc/contributing_rdoc.html Thanks! ---------------------------------------- Bug #18983: Range#size for beginless Range is not nil. https://bugs.ruby-lang.org/issues/18983#change-99138 * 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: