Project

General

Profile

Actions

Bug #15987

closed

Let `exception` option in `Kernel#Complex`, `Kernel#Float`, `Kernel#Integer`, `Kernel#Rational` be falsy vs. truthy

Added by sawa (Tsuyoshi Sawada) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:93552]

Description

The exception option in Kernel#Complex, Kernel#Float, Kernel#Integer, and Kernel#Rational distinguishes false vs. other values.

Integer("z", exception: false) #=> nil
Integer("z", exception: nil) #>> ArgumentError: invalid value for Integer(): "z")

But in most other cases where a boolean notion is concerned (for example, the chomp option in Kernel#gets), the distinction is between falsy vs. truthy values.

I request the distinction to be falsy vs. truthy. In other words, I would like the value nil to work on the falsy side rather than the truthy side like this.

Integer("z", exception: false) #=> nil
Integer("z", exception: nil) #=> nil
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0