Skip to content
  • Kazuhiro NISHIYAMA's avatar
    e2b192f7
    rand(beginless_range) raise Errno::EDOM instead of TypeError · e2b192f7
    Kazuhiro NISHIYAMA authored
    same as `rand(endless_range)`
    
    Before:
    ```
    $ ruby -e 'rand(..1)'
    Traceback (most recent call last):
    	2: from -e:1:in `<main>'
    	1: from -e:1:in `rand'
    -e:1:in `-': nil can't be coerced into Integer (TypeError)
    ```
    
    After:
    ```
    $ ruby -e 'rand(..1)'
    Traceback (most recent call last):
    	1: from -e:1:in `<main>'
    -e:1:in `rand': Numerical argument out of domain (Errno::EDOM)
    ```
    e2b192f7
    rand(beginless_range) raise Errno::EDOM instead of TypeError
    Kazuhiro NISHIYAMA authored
    same as `rand(endless_range)`
    
    Before:
    ```
    $ ruby -e 'rand(..1)'
    Traceback (most recent call last):
    	2: from -e:1:in `<main>'
    	1: from -e:1:in `rand'
    -e:1:in `-': nil can't be coerced into Integer (TypeError)
    ```
    
    After:
    ```
    $ ruby -e 'rand(..1)'
    Traceback (most recent call last):
    	1: from -e:1:in `<main>'
    -e:1:in `rand': Numerical argument out of domain (Errno::EDOM)
    ```
Loading