Submitted by anonymous (Thu Aug 21 14:08:13 UTC 2003)
puts "something" if any(2,5,8) == 3<br>or:
if all(x,y,z)
def initialize(ary)<br> @ary = ary<br> end<br>
def ==(*ary)<br> @ary.each{|i|<br> ary.each{|j|<br>
return false unless i == j
}<br> }<br> return true<br> end<br>
def @ary.each{|i|<br> ary.each{|j|<br>
return false if i> j
}<br> }<br> return true<br> end<br>
def&gt;(*ary)<br> @ary.each{|i|<br> ary.each{|j|<br>
return false if i
}<br> }<br> return true<br> end<br>end
return All.new(ary)<br>end
Comments | Current voting | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
RCRchive copyright © David Alan Black, 2003-2005.
Powered by .
Ruby-Junction does this (cout, 2003-08-21 14:21:02)
quantum operations? (, 2003-08-21 15:34:25)
Ruby 1.8: Enumerable#any? and Enumerable#all? (whytheluckystif, 2003-08-21 20:30:22)
These are in 1.8.0.
or:
So, if you leave off a block, it defaults to checking of the elements of the Enumerable evaluate as booleans to
true
.See my >1.8.0 summary page for more on these.