From: James Gray Date: 2009-04-19T23:21:00+09:00 Subject: Re: [ANN] Junctions for Ruby1.9 (Lab419::functional-0.1.2) On Apr 18, 2009, at 4:38 PM, Denis Defreyne wrote: > On Apr 17, 2009, at 11:17 PM, Robert Dober wrote: > >> E.g. >> >> any(1, 2, 3) > 2 --> true >> [ 1, 3, 5 ].all.odd? --> true >> none( 1 ).zero? --> true >> all() == nil --> true >> any() == nil --> false > > The examples you gave are equivalent to > ![ 1 ].any? { |e| e.zero? } Or: not [1].include? 0 > [].all? { |e| e == nil } Or: a = [] a.nitems == a.size > [].any? { |e| e == nil } Or: a.nitems > 0 Ruby 1.9's Enumerable#none?() and Enumerable#one?() also help out with tests like this. James Edward Gray II