mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[DOC] Described "numeric representation" more precisely [ci skip]
[Bug #17395]
This commit is contained in:
parent
efc6a4e580
commit
a039dc018c
1 changed files with 4 additions and 2 deletions
6
object.c
6
object.c
|
@ -3372,8 +3372,9 @@ rb_opts_exception_p(VALUE opts, int default_value)
|
||||||
* integer string representation. If <i>arg</i> is a String,
|
* integer string representation. If <i>arg</i> is a String,
|
||||||
* when <i>base</i> is omitted or equals zero, radix indicators
|
* when <i>base</i> is omitted or equals zero, radix indicators
|
||||||
* (<code>0</code>, <code>0b</code>, and <code>0x</code>) are honored.
|
* (<code>0</code>, <code>0b</code>, and <code>0x</code>) are honored.
|
||||||
* In any case, strings should be strictly conformed to numeric
|
* In any case, strings should consist only of one or more digits, except
|
||||||
* representation. This behavior is different from that of
|
* 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
|
* String#to_i. Non string values will be converted by first
|
||||||
* trying <code>to_int</code>, then <code>to_i</code>.
|
* trying <code>to_int</code>, then <code>to_i</code>.
|
||||||
*
|
*
|
||||||
|
@ -3387,6 +3388,7 @@ rb_opts_exception_p(VALUE opts, int default_value)
|
||||||
* Integer(Time.new) #=> 1204973019
|
* Integer(Time.new) #=> 1204973019
|
||||||
* Integer("0930", 10) #=> 930
|
* Integer("0930", 10) #=> 930
|
||||||
* Integer("111", 2) #=> 7
|
* Integer("111", 2) #=> 7
|
||||||
|
* Integer(" +1_0 ") #=> 10
|
||||||
* Integer(nil) #=> TypeError: can't convert nil into Integer
|
* Integer(nil) #=> TypeError: can't convert nil into Integer
|
||||||
* Integer("x") #=> ArgumentError: invalid value for Integer(): "x"
|
* Integer("x") #=> ArgumentError: invalid value for Integer(): "x"
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue