Created
March 24, 2011 13:43
-
-
Save llimllib/885072 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* ed: line 126-143 of enum.c */ | |
/* | |
* call-seq: | |
* enum.count -> int | |
* enum.count(item) -> int | |
* enum.count {| obj | block } -> int | |
* | |
* Returns the number of items in <i>enum</i>, where #size is called | |
* if it responds to it, otherwise the items are counted through | |
* enumeration. If an argument is given, counts the number of items | |
* in <i>enum</i>, for which equals to <i>item</i>. If a block is | |
* given, counts the number of elements yielding a true value. | |
* | |
* ary = [1, 2, 4, 2] | |
* ary.count #=> 4 | |
* ary.count(2) #=> 2 | |
* ary.count{|x|x%2==0} #=> 3 | |
* | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment