nonzero?

num.nonzero? รข self or nil
Instance Public methods

Returns self if num is not zero, nil otherwise. This behavior is useful when chaining comparisons:

a = %w( z Bb bB bb BB a aA Aa AA A )
b = a.sort {|a,b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
b   #=> ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
doc_ruby_on_rails
2015-04-23 00:44:33
Comments
Leave a Comment

Please login to continue.