Skip to content

Instantly share code, notes, and snippets.

@jaredatron
Created May 5, 2009 19:58
Show Gist options
  • Select an option

  • Save jaredatron/107166 to your computer and use it in GitHub Desktop.

Select an option

Save jaredatron/107166 to your computer and use it in GitHub Desktop.
class Regexp
def to_proc
lambda{|*args| (matches = args.shift.match(self)) ? matches.to_a.first : nil}
end
end
example = %w(love me inside your face)
puts example.find_all(&/^l|y|f/).inspect
puts example.map(&/^l|y|f/).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment