From: John Sikora Date: 2010-07-31T03:22:44+09:00 Subject: Re: .any?{} Behavior Rick Denatale wrote: > By convention the universal quantifier evaluates to true for an empty > set: > http://en.wikipedia.org/wiki/Universal_quantification#The_empty_set > http://en.wikipedia.org/wiki/Vacuous_truth >> Well, that seals it for me. My thinking is wrong if it goes against convention, not only in Ruby, but in universal quantification. > > For library code, such as in a gem I think it would be better to think > up some other method name rather than changing the standard, e.g. > > module Enumerable > def non_vacuous_all?(&b) > !empty? && all?(&b) > end > end > > [3].all? {|element| element == 3 } # => true > [3].all? {|element| element != 3 } # => false > > [].all? {|element| element == 3 } # => true > [].all? {|element| element != 3 } # => true > > [3].non_vacuous_all? {|element| element == 3 } # => true > [3].non_vacuous_all? {|element| element != 3 } # => false > > [].non_vacuous_all? {|element| element == 3 } # => false > [].non_vacuous_all? {|element| element != 3 } # => false > > [].any? {|element| element == 3 } # => false > [].any? {|element| element != 3 } # => false > > There may be a better name than non_vacuous_all? but I can't think of > one. > Agreed, I should use a similar technigue for my specific applications. js -- Posted via http://www.ruby-forum.com/.