What is the proper syntax for a method that checks a string for a pattern, and returns true or false if the regex matches?
Basic idea:
def has_regex?(str
Your code looks fine, but you could write it even smaller.
The return value of String#=~ behaves this way:
nil if the pattern did not matchIn Ruby everything except nil and false behaves like true in a conditional statement so you can just write
if string=~ pattern
# do something
else
# panic
end