Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparable#clamp(min, max) にnilを渡した際の挙動を追加 #2801

Merged
merged 1 commit into from Apr 25, 2023

Conversation

kyanagi
Copy link
Contributor

@kyanagi kyanagi commented Apr 21, 2023

もともと仕様では定められていなかったのですが、Ruby 3.0 からこの挙動をします。

% docker run -it --rm rubylang/all-ruby env ALL_RUBY_SINCE=ruby-2.7.0 ./all-ruby -e "p 5.clamp(0, nil)"
ruby-2.7.0          -e:1:in `clamp': comparison of Integer with nil failed (ArgumentError)
                        from -e:1:in `<main>'
                exit 1
...
ruby-2.7.8          -e:1:in `clamp': comparison of Integer with nil failed (ArgumentError)
                        from -e:1:in `<main>'
                exit 1
ruby-3.0.0-preview1 5
...
ruby-3.2.2          5

このたび仕様と認められたので、ドキュメントに追記します。
https://bugs.ruby-lang.org/issues/19588

https://bugs.ruby-lang.org/issues/19588
3.0からこの挙動で、追認する形で仕様と認められた。
@znz znz merged commit 0b787bd into rurema:master Apr 25, 2023
14 checks passed
@kyanagi kyanagi deleted the comparable_clamp_nil branch April 28, 2023 06:55
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.

None yet

2 participants