[ruby-core:113910] [Ruby master Bug#19733] Kernel#Rational does not accept prefix 0
From:
"sawa (Tsuyoshi Sawada) via ruby-core" <ruby-core@...>
Date:
2023-06-15 00:44:52 UTC
List:
ruby-core #113910
Issue #19733 has been reported by sawa (Tsuyoshi Sawada).
----------------------------------------
Bug #19733: Kernel#Rational does not accept prefix 0
https://bugs.ruby-lang.org/issues/19733
* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
`Integer` and `Rational` literals accept prefix `0`. There is no difference in this respect.
```ruby
0b10 # => 2
0b10r # => (2/1)
```
However, when it comes to `Kernel#Integer` and `Kernel#Rational`, the former accept prefix `0` while the latter does not. This is confusing. And as I do not see any reason they should behave differently, I think it is a bug.
```ruby
Integer("0b10") # => 2
Rational("0b10") # !> ArgumentError
```
--
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/postorius/lists/ruby-core.ml.ruby-lang.org/