Project

General

Profile

Actions

Feature #9123

open

Make Numeric#nonzero? behavior consistent with Numeric#zero?

Added by sferik (Erik Michaels-Ober) over 10 years ago. Updated almost 5 years ago.

Status:
Open
Target version:
-
[ruby-core:58404]

Description

Numeric#zero? returns true or false, while Numeric#nonzero? returns self or nil.

I've written a patch that fixes this inconsistency and adds a Numeric#nonzero (non-predicate) method that returns self or nil for chaining comparisons. I'd like for this to be included in Ruby 2.1.0.

https://github.com/ruby/ruby/pull/452.patch

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0