Issue #13992 has been updated by Ursus (Ivan Lasorsa).


zverok (Victor Shepelev) wrote:
> Yes, it does. Leading zero designates octal number (base 8), which can't have digit "8" in it.

~~~ ruby
Integer('09', 10)
9
~~~

This works as expected. My fault thinking that 10 should be the default base

----------------------------------------
Bug #13992: Strange behaviour for kernel#integer method
https://bugs.ruby-lang.org/issues/13992#change-67139

* Author: Ursus (Ivan Lasorsa)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.4.1
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
I tried this one with ruby 2.3.1 and ruby 2.4.1.

~~~ ruby
Integer('04')
4
Integer('05')
5
Integer('08')
ArgumentError: invalid value for Integer(): "08"
Integer('09')
ArgumentError: invalid value for Integer(): "09"
~~~

Does this makes sense?



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>