From: Sakuro OZAWA Date: 2010-08-12T13:42:47+09:00 Subject: [ruby-core:31685] [RubySpec #3684] String#to_i documentation mismatch RubySpec #3684: String#to_i documentation mismatch http://redmine.ruby-lang.org/issues/show/3684 Author: Sakuro OZAWA Status: Open, Priority: Low Category: DOC, Target version: 1.9.1 RC2 Missing: Giving base 0 makes this method take prefix into account. ex. "0xFF".to_i(0) #=> 255 Wrong: string.c rb_str_to_i says: This method never raises an exception. But it raises * ArgumentError when the given base is out of range * TypeError when converting the base into Integer is failed % ruby -ve '"123".to_i(99)' ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-linux] -e:1:in `to_i': invalid radix 99 (ArgumentError) from -e:1:in `
' % ruby -ve '"123".to_i(nil)' ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-linux] -e:1:in `to_i': no implicit conversion from nil to integer (TypeError) from -e:1:in `
' % ruby -ve '"123".to_i(false)' ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-linux] -e:1:in `to_i': can't convert false into Integer (TypeError) from -e:1:in `
' ---------------------------------------- http://redmine.ruby-lang.org