Skip to content

Fix Range#max for beginless Integer ranges#3328

Merged
nobu merged 3 commits intoruby:masterfrom
citizen428:citizen428/beginless-range-max
Jul 18, 2020
Merged

Fix Range#max for beginless Integer ranges#3328
nobu merged 3 commits intoruby:masterfrom
citizen428:citizen428/beginless-range-max

Conversation

@citizen428
Copy link
Copy Markdown
Contributor

Proposed solution for Bug #17034

Summary

Getting the maximum of a beginless range leads to an unintuitive error:

(..2).max
# ArgumentError: comparison of NilClass with 2 failed

This PR fixes that without changing any other behavior:

(..2).max
#=> 2
(...2).max 
# TypeError (cannot exclude end value with non Integer begin value)
(...2.0).max'
# TypeError (cannot exclude non Integer end value)

citizen428 and others added 2 commits July 18, 2020 22:13
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
@nobu nobu merged commit 8a5ad2b into ruby:master Jul 18, 2020
@citizen428 citizen428 deleted the citizen428/beginless-range-max branch July 21, 2020 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants