Issue #9123 has been updated by alexeymuranov (Alexey Muranov).


BertramScharpf (Bertram Scharpf) wrote:
> 
> That's a matter of taste. In my eyes, this code example is beautiful and clear.
> It could be more efficient using #casecmp instead of two #downcases, what you
> clearly can see if it is one line.

I do not understand what is a matter of taste here.  Everybody seems to agree that the only problem is the compatibility.  How would the following be less beautiful or clear?

  a.sort {|a,b| (a.downcase <=> b.downcase).nonzero || a <=> b }

or

  a.sort {|a,b| (a.downcase <=> b.downcase).non(0) || a <=> b }

----------------------------------------
Feature #9123: Make Numeric#nonzero? behavior consistent with Numeric#zero?
https://bugs.ruby-lang.org/issues/9123#change-43114

Author: sferik (Erik Michaels-Ober)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


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


-- 
http://bugs.ruby-lang.org/