Skip to content

Instantly share code, notes, and snippets.

@benhoskings
Forked from lachlanhardy/gist:70614
Created February 26, 2009 03:19
Show Gist options
  • Select an option

  • Save benhoskings/70626 to your computer and use it in GitHub Desktop.

Select an option

Save benhoskings/70626 to your computer and use it in GitHub Desktop.
class Array
def count_if
inject(0) {|acc, i| acc + (yield(i) ? 1 : 0) }
end
end
def f(ra,n)
ra.count_if {|x| x.include? n }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment