match?
over match
RB-PR1018String#match?
, Regexp#match?
, and Symbol#match?
are faster than match
, because the methods avoid creating a MatchData
object or saving backref. So, when MatchData
is not used, match?
can be used instead of match
.
def foo
if x =~ /re/
do_something
end
end
def foo
if x.match?(/re/)
do_something
end
end