Created
March 26, 2012 17:05
-
-
Save THUFIR/2206528 to your computer and use it in GitHub Desktop.
cats
This file contains 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
line1 = "Cats are smarter than dogs"; | |
line2 = "Dogs also like meat"; | |
if ( line1 =~ /Cats(.*)/ ) | |
puts "Line1 starts with Cats" | |
end | |
if ( line2 =~ /Cats(.*)/ ) | |
puts "Line2 starts with Dogs" | |
end | |
def match (s) | |
result = case s | |
when (s =~ /Cats(.*)/ ) then "cats" | |
else "no cats" | |
end | |
puts result | |
end | |
match(line1) | |
match(line2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment