Re:JRuby 9000 released
by jrochkind1 on Wednesday July 22, 2015 @07:44PM
(#9933107)
Huh, I use `$1` all the time, and see it all the time. Probably because the alternative with an explicit match object ends up being relatively a lot more code and a lot harder to read, really.
If avoiding `$1` has been often recommended for a while... I think it's a recommendation more often ignored than followed.
Re:JRuby 9000 released
by thescrewdriver on Thursday July 23, 2015 @04:27AM
(#9934586)
I've never seen $1 used in production code.
Try grepping your lib directory sometime. In fact, let me do it for you, on a relatively clean install:
time, benchmark, irb, pry, rubygems, resolv, erb, rake, open-uri, debug, rack, cgi/util, optparse, getoptlong, bundler, activesupport, actionpack, activemodel, erubis, slim, haml, sass, sequel, roda, nokogiri, rugged, faraday, mime-types, thor, test-unit, tzinfo, mail, ffi
Re:JRuby 9000 released
by thescrewdriver on Wednesday July 29, 2015 @06:51AM
(#9967708)
Ouch. That's pretty awful.
Re:JRuby 9000 released
by VeejayRampay on Thursday July 23, 2015 @03:27AM
(#9934441)
I don't think it's that common a pattern. All those perlisms make code unreadable anyway. I much prefer things like match with named captures, which generally make everything more obvious.
Is it really? Even fairly early in the Ruby 1.8.x era, most recommendations I saw were that the magic regexp globals (and many other magic globals) were a perlism that should generally be avoided.