3 ms·
$~ and friends are not global: def f p $~ # => nil "123" =~ /\w+/ p $~ # => #<MatchData "123"> end p $~ # => nil "abc" =~ /\w+/ p $~ # =
by infraruby 11y ago
$~ and friends are not global:
def f
p $~ # => nil
"123" =~ /\w+/
p $~ # => #<MatchData "123">
end
p $~ # => nil
"abc" =~ /\w+/
p $~ # => #<MatchData "abc">
f
p $~ # => #<MatchData "abc">
- headius 11y agoMatz himself has said he regrets putting these variables in the language, and some day they may disappear. We'll match behavior as much as possible, but they're a relic no matter how you slice it.