Skip to content

Instantly share code, notes, and snippets.

@llimllib
Created March 24, 2011 13:43
Show Gist options
  • Save llimllib/885072 to your computer and use it in GitHub Desktop.
Save llimllib/885072 to your computer and use it in GitHub Desktop.
/* 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