Project

General

Profile

Bug #15452 ยป document-exceptions.patch

zverok (Victor Shepelev), 12/22/2018 07:46 PM

View differences:

complex.c
394 394

  
395 395
/*
396 396
 * call-seq:
397
 *    Complex(x[, y])  ->  numeric
397
 *    Complex(x[, y], exception: false)  ->  numeric
398 398
 *
399 399
 * Returns x+i*y;
400 400
 *
......
403 403
 *    Complex(nil)     #=> TypeError
404 404
 *    Complex(1, nil)  #=> TypeError
405 405
 *
406
 *    Complex(1, nil, exception: false) # => nil
407
 *    Complex('1+2', exception: false) # => nil
408
 *
406 409
 * Syntax of string form:
407 410
 *
408 411
 *   string form = extra spaces , complex , extra spaces ;
object.c
3221 3221

  
3222 3222
/*
3223 3223
 *  call-seq:
3224
 *     Integer(arg, base=0)    -> integer
3224
 *     Integer(arg, base=0, exception: true)    -> integer
3225 3225
 *
3226 3226
 *  Converts <i>arg</i> to an <code>Integer</code>.
3227 3227
 *  Numeric types are converted directly (with floating point numbers
......
3232 3232
 *  In any case, strings should be strictly conformed to numeric
3233 3233
 *  representation. This behavior is different from that of
3234 3234
 *  <code>String#to_i</code>.  Non string values will be converted by first
3235
 *  trying <code>to_int</code>, then <code>to_i</code>. Passing <code>nil</code>
3236
 *  raises a TypeError.
3235
 *  trying <code>to_int</code>, then <code>to_i</code>.
3236
 *
3237
 *  Passing <code>nil</code> raises a TypeError, while passing String that
3238
 *  does not conform with numeric representation raises an ArgumentError.
3239
 *  This behavior can be altered by passing <code>exception: false</code>,
3240
 *  in this case not convertible value will return <code>nil</code>.
3237 3241
 *
3238 3242
 *     Integer(123.999)    #=> 123
3239 3243
 *     Integer("0x1a")     #=> 26
3240 3244
 *     Integer(Time.new)   #=> 1204973019
3241 3245
 *     Integer("0930", 10) #=> 930
3242 3246
 *     Integer("111", 2)   #=> 7
3243
 *     Integer(nil)        #=> TypeError
3247
 *     Integer(nil)        #=> TypeError: can't convert nil into Integer
3248
 *     Integer("x")        #=> ArgumentError: invalid value for Integer(): "x"
3249
 *
3250
 *     Integer("x", exception: false)        #=> nil
3251
 *
3244 3252
 */
3245 3253

  
3246 3254
static VALUE
......
3575 3583

  
3576 3584
/*
3577 3585
 *  call-seq:
3578
 *     Float(arg)    -> float
3586
 *     Float(arg, exception: true)    -> float
3579 3587
 *
3580 3588
 *  Returns <i>arg</i> converted to a float. Numeric types are converted
3581 3589
 *  directly, and with exception to string and nil the rest are converted using <i>arg</i>.to_f.
3582 3590
 *  Converting a <code>string</code> with invalid characters will result in a <code>ArgumentError</code>.
3583 3591
 *  Converting <code>nil</code> generates a <code>TypeError</code>.
3592
 *  Exceptions could be suppressed by passing <code>exception: false</code>.
3584 3593
 *
3585 3594
 *     Float(1)                 #=> 1.0
3586 3595
 *     Float("123.456")         #=> 123.456
3587 3596
 *     Float("123.0_badstring") #=> ArgumentError: invalid value for Float(): "123.0_badstring"
3588 3597
 *     Float(nil)               #=> TypeError: can't convert nil into Float
3598
 *     Float("123.0_badstring", exception: false)  #=> nil
3589 3599
 */
3590 3600

  
3591 3601
static VALUE
rational.c
529 529

  
530 530
/*
531 531
 * call-seq:
532
 *    Rational(x, y)  ->  rational
533
 *    Rational(arg)   ->  rational
532
 *    Rational(x, y, exception: true)  ->  rational
533
 *    Rational(arg, exception: true)   ->  rational
534 534
 *
535 535
 * Returns +x/y+ or +arg+ as a Rational.
536 536
 *
......
546 546
 *    Rational(nil)         #=> TypeError
547 547
 *    Rational(1, nil)      #=> TypeError
548 548
 *
549
 *    Rational("10 cents", exception: false)  #=> nil
550
 *
549 551
 * Syntax of the string form:
550 552
 *
551 553
 *   string form = extra spaces , rational , extra spaces ;