Skip to content

Instantly share code, notes, and snippets.

@magnusstahre
Forked from rdammkoehler/good_and_bad.rb
Created May 3, 2012 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magnusstahre/2582841 to your computer and use it in GitHub Desktop.
Save magnusstahre/2582841 to your computer and use it in GitHub Desktop.
Stuff I'm doing
def good_or_bad lines, patterns
lines.zip(patterns).all? { |(line, pattern)|
line.match pattern
}
end
lines = [ "line1", "line2", "line3" ]
patterns = [ "pattern1", "pattern2", "pattern3" ]
puts lines.zip patterns #=> [["line1", "pattern1"], ["line2", "pattern2"], ["line3", "pattern3"]] 
good_or_bad lines, patterns #=> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment