From: "mame (Yusuke Endoh) via ruby-core" Date: 2025-12-17T09:32:17+00:00 Subject: [ruby-core:124281] [Ruby Bug#21174] Range#max called with an argument on a beginless Integer Range raises RangeError Issue #21174 has been updated by mame (Yusuke Endoh). I confirmed @matz and he said that the current behavior is OK. He prioritizes practicality over consistency in this case. ---------------------------------------- Bug #21174: Range#max called with an argument on a beginless Integer Range raises RangeError https://bugs.ruby-lang.org/issues/21174#change-115778 * Author: andrykonchin (Andrew Konchin) * Status: Closed * ruby -v: 3.4.2 * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- It seems surprising but instead of returning last `n` Integers `Range#max(n)` raises `RangeError`: ```ruby (nil..10).max(2) # => (irb):3:in 'Range#max': cannot get the maximum of beginless range with custom comparison method (RangeError) ``` I would expect `[9, 10]` to be returned. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/