How to change this ruby match line to return true or false

Viewed 68

Ok so my ruby is rusty. I have a line that looks for a match...

self.volunteer_event.description.match(/^Roster #/)

gives me this...

[1] pry(#<VolunteerShift>)> self.volunteer_event.description.match(/^Roster #/)
=> #<MatchData "Roster #">

I want to change it to give me "true" if it has a match or "false" for no

What simple ruby incantation can I use to achieve this?

1 Answers

Looking at the Regexp docs, I see match? and match. Use match? which returns a boolean. Functions that return a boolean often end with ? in Ruby.

Related