Method: Enumerable#all?
- Defined in:
- enum.c
#all? {|obj| ... } ⇒ Boolean
Passes each element of the collection to the given block. The method returns true if the block never returns false or nil. If the block is not given, Ruby adds an implicit block of { |obj| obj } which will cause #all? to return true when none of the collection members are false or nil.
%w[ant bear cat].all? { |word| word.length >= 3 } #=> true
%w[ant bear cat].all? { |word| word.length >= 4 } #=> false
[nil, true, 99].all? #=> false
1052 1053 1054 1055 1056 1057 1058 |
# File 'enum.c', line 1052
static VALUE
enum_all(VALUE obj)
{
NODE *memo = NEW_MEMO(Qtrue, 0, 0);
rb_block_call(obj, id_each, 0, 0, ENUMFUNC(all), (VALUE)memo);
return memo->u1.value;
}
|