Hi,
In message "[ruby-talk:16591] RCR: Enumerable: every() and none()"
on 01/06/19, Hugh Sasse Staff Elec Eng <hgs / dmu.ac.uk> writes:
|Enumerable should have functions every and none to complement find_all
|and reject. I think it is likely that people will want to know if all
|the things in the enumObj match or all don't match the conditions
|specified by block. So:
|
|def every(&block)
| find_all(&block) == to_a()
|end
|
|def none(&block)
| reject(&block) == to_a()
|end
In 1.7, we have "Enumerable#all?" and "Enumerable#any?".
[1,2,3].all?{|x| > 0} # true
[1,2,3].any?{|x| == 2} # true
matz.