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

Revise Rational#quo documentation #2143

Merged
merged 1 commit into from Mar 10, 2020
Merged

Revise Rational#quo documentation #2143

merged 1 commit into from Mar 10, 2020

Conversation

pocke
Copy link
Member

@pocke pocke commented Feb 11, 2020

Rational#quo のドキュメントを修正します。

ここで「other に Float を指定した場合は、計算結果を Float で返します。ただし 0 以外の整数に等しい場合は Rational で返します。」と書かれています。
ですが、「ただし 0 以外の整数に等しい場合は Rational で返します。」は現在の挙動と異なるようでした。現在はotherがFloatの場合は戻り値もFloatになっています。
「ただし 0 以外の整数に等しい場合は Rational で返します。」というのは、1.9.3と2.0.0のみの挙動のようです。

$ docker run -it --rm rubylang/all-ruby env ALL_RUBY_SINCE=ruby-1.8.0 ./all-ruby -rrational -e 'p Rational(3, 4) / 2.0'
ruby-1.8.0            0.375
...
ruby-1.9.2-p330       0.375
ruby-1.9.3-preview1   (3/8)
...
ruby-2.0.0-p648       (3/8)
ruby-2.1.0-preview1   0.375
...
ruby-2.7.0            0.375

どうやら色々あって変更がrevertされたようです。
https://bugs.ruby-lang.org/issues/5515

そのため、ドキュメントの記述も実際の挙動に合わせて修正しています。

なお、サンプルコードには実際の挙動に合った戻り値が書かれているので修正は不要でした ✔️

```
$ docker run -it --rm -v /tmp/test.rb:/home/pocke/ghq/github.com/ruby/ruby/test.rb rubylang/all-ruby env ALL_RUBY_SINCE=ruby-1.8.0 ./all-ruby -rrational -e 'p Rational(3, 4) / 2.0'
ruby-1.8.0            0.375
...
ruby-1.9.2-p330       0.375
ruby-1.9.3-preview1   (3/8)
...
ruby-2.0.0-p648       (3/8)
ruby-2.1.0-preview1   0.375
...
ruby-2.7.0            0.375
```

see https://bugs.ruby-lang.org/issues/5515
@znz znz merged commit 4f14863 into rurema:master Mar 10, 2020
@pocke pocke deleted the Rational#quo branch March 10, 2020 11: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