
Issue #19733 has been updated by mame (Yusuke Endoh). Status changed from Open to Feedback "Confusing" is not nessecarily a bug. What Kernel#Rational accepts is clearly stated in the documentation in BNF style. https://docs.ruby-lang.org/en/master/Kernel.html#method-i-Rational There may be room for discussion to make `Kernel#Rational` accept 0x10, though I personally don't need it. An explanation of a use case would help the discussion. ---------------------------------------- Bug #19733: Kernel#Rational does not accept prefix 0 https://bugs.ruby-lang.org/issues/19733#change-103563 * Author: sawa (Tsuyoshi Sawada) * Status: Feedback * 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 accepts 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/