Created
April 8, 2010 19:56
-
-
Save zeroeth/360458 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* call-seq: | |
* enum.all? [{|obj| block } ] => true or false | |
* | |
* Passes each element of the collection to the given block. The method | |
* returns <code>true</code> if the block never returns | |
* <code>false</code> or <code>nil</code>. If the block is not given, | |
* Ruby adds an implicit block of <code>{|obj| obj}</code> (that is | |
* <code>all?</code> will return <code>true</code> only if none of the | |
* collection members are <code>false</code> or <code>nil</code>.) | |
* | |
* %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 | |
* | |
*/ | |
static VALUE | |
enum_all(obj) | |
VALUE obj; | |
{ | |
VALUE result = Qtrue; | |
rb_iterate(rb_each, obj, rb_block_given_p() ? all_iter_i : all_i, (VALUE)&result); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment