From 2066e50c411ffd14f3949c417036def5f5a80ee4 Mon Sep 17 00:00:00 2001 From: Ryan Ringler Date: Fri, 3 Mar 2017 20:11:48 -0800 Subject: [PATCH] Adds Documentation for String#to_i(0) Adds documentation for calling `String#to_i(0)`. Only today I learned that if `#to_i` is passed with an argument `0`, it will honor radix indicators ('0b', '0o', '0d', '0x') at the beginning of the string. --- string.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/string.c b/string.c index e93af5ceceb4ba..97c13b58ae748d 100644 --- a/string.c +++ b/string.c @@ -4995,10 +4995,12 @@ rb_str_include(VALUE str, VALUE arg) * str.to_i(base=10) -> integer * * Returns the result of interpreting leading characters in str as an - * integer base base (between 2 and 36). Extraneous characters past the - * end of a valid number are ignored. If there is not a valid number at the - * start of str, 0 is returned. This method never raises an - * exception when base is valid. + * integer base base (either 0 or between 2 and 36). If a base of 0 is + * passed, radix indicators ('0b', '0o', '0d', '0x') at the beginning of the + * string will be honored. Extraneous characters past the end of a valid number + * are ignored. If there is not a valid number at the start of str, + * 0 is returned. This method never raises an exception when + * base is valid. * * "12345".to_i #=> 12345 * "99 red balloons".to_i #=> 99