ruby-changes:64189
From: Nobuyoshi <ko1@a...>
Date: Wed, 16 Dec 2020 00:12:58 +0900 (JST)
Subject: [ruby-changes:64189] a039dc018c (master): [DOC] Described "numeric representation" more precisely [ci skip]
https://git.ruby-lang.org/ruby.git/commit/?id=a039dc018c From a039dc018ccf34e217f767eac500b9400c58f069 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 16 Dec 2020 00:07:37 +0900 Subject: [DOC] Described "numeric representation" more precisely [ci skip] [Bug #17395] diff --git a/object.c b/object.c index 7343bd6..552b10b 100644 --- a/object.c +++ b/object.c @@ -3372,8 +3372,9 @@ rb_opts_exception_p(VALUE opts, int default_value) https://github.com/ruby/ruby/blob/trunk/object.c#L3372 * integer string representation. If <i>arg</i> is a String, * when <i>base</i> is omitted or equals zero, radix indicators * (<code>0</code>, <code>0b</code>, and <code>0x</code>) are honored. - * In any case, strings should be strictly conformed to numeric - * representation. This behavior is different from that of + * In any case, strings should consist only of one or more digits, except + * for that a sign, one underscore between two digits, and leading/trailing + * spaces are optional. This behavior is different from that of * String#to_i. Non string values will be converted by first * trying <code>to_int</code>, then <code>to_i</code>. * @@ -3387,6 +3388,7 @@ rb_opts_exception_p(VALUE opts, int default_value) https://github.com/ruby/ruby/blob/trunk/object.c#L3388 * Integer(Time.new) #=> 1204973019 * Integer("0930", 10) #=> 930 * Integer("111", 2) #=> 7 + * Integer(" +1_0 ") #=> 10 * Integer(nil) #=> TypeError: can't convert nil into Integer * Integer("x") #=> ArgumentError: invalid value for Integer(): "x" * -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/