Project

General

Profile

Actions

Feature #11627

open

make `nonzero` an alias of `nonzero?`

Added by Anonymous about 9 years ago. Updated 8 months ago.

Status:
Assigned
Target version:
-
[ruby-core:71233]

Description

for historic reasons nonzero? returns self or nil. (according to https://bugs.ruby-lang.org/issues/9123)

I like the expectation that method? returns true and false.
That nonzero? returns only truthy/falsy values would be fine, except using its return values are useful.

value.nonzero? || calculation or (a <=> b).nonzero? || a.subvalue <=> b.subvalue

I would feel more comfortable with value.nonzero || calculation even though it is only one character different.

Yes, it's a small thing, but I like ruby for the small things :)

Thanks.

Updated by marcandre (Marc-Andre Lafortune) about 9 years ago

  • Assignee set to matz (Yukihiro Matsumoto)

When you say "for historic reasons nonzero? returns self or nil", it sounds like it was a mistake that can't be fixed for compatibility reason. I don't believe this to be true.

Also, do you also want Module#< and al. to be renamed?

String < Fixnum # => nil
Actions #2

Updated by hsbt (Hiroshi SHIBATA) almost 3 years ago

  • Project changed from 14 to Ruby master
Actions #3

Updated by hsbt (Hiroshi SHIBATA) 8 months ago

  • Status changed from Open to Assigned
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0