From: "alexeymuranov (Alexey Muranov)" Date: 2013-11-23T19:03:17+09:00 Subject: [ruby-core:58521] [ruby-trunk - Feature #9123] Make Numeric#nonzero? behavior consistent with Numeric#zero? Issue #9123 has been updated by alexeymuranov (Alexey Muranov). fuadksd (Fuad Saud) wrote: > I don't understand why we would want to be so strict about types on this > case. Having some arbitrary value being returned is useful and it doesn't > hurt any good practices. Ensuring predicates return true or false feels > useless for me In my opinion, it is because code is intended mostly for reading, not for writing. a.sort {|a,b| (a.downcase <=> b.downcase).nonzero? || a <=> b } is unexpected or confusing. ---------------------------------------- Feature #9123: Make Numeric#nonzero? behavior consistent with Numeric#zero? https://bugs.ruby-lang.org/issues/9123#change-43102 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/