r/ruby • u/jbackus • Jul 20 '16
New Features in Ruby 2.4
http://blog.blockscore.com/new-features-in-ruby-2-4/2
u/ilmari2k Jul 20 '16
The regexp match might yield some performance benefits if done multiple times inside a large loop for example. Is it find/replaceable?
2
u/jbackus Jul 20 '16
What exactly do you mean by "find/replaceable"?
3
u/lordp Jul 21 '16
I think they mean replacing all uses of Regexp#match with Regexp#match?. The answer would be maybe, depending on whether you care about the content of the match or not.
1
2
u/berkes Jul 21 '16
I'd say no.
#match?is for when you only care that there is a match,#matchfor when you actually want to do something with it. Which is hard to detect in a find-replace-batch because theMatchDatamight be used elsewhere, without an obvious assigment or passing around of variables.They have different usecases. And unless you are 100% sure all your usage of
#matchfit in the "only check if it is matching, never using the matched data" you cannot do a search-replace.
10
Jul 20 '16
The sad life of a library maintainer is that you can't use cool new features until they've been out several years...
4
2
u/gvieira37 Jul 20 '16
Same here. Also, I use Ruby at old Windows machines with outdated libs, so most of times I'm still using 1.9.3. Really sad!
2
u/tas50 Jul 21 '16
We're starting to see Ruby 2.1 support dropped from the major libraries though so the cool stuff is arriving slowly. We're always a few years behind, but better late then never.
1
u/tsujp Jul 21 '16
Why can't you have two versions:
Super stable works everywhere version.
Stable works with newest ruby version.
4
Jul 21 '16
For me, at least, maintaining multiple branches is a lot more work than just waiting until old Ruby versions can be left behind.
2
u/HellzStormer Jul 20 '16
Your blog seems to have interesting stuff, but it's a bit of a pain to navigate without an easily accessible index of all the posts.
Am I dumb or is there no index?
2
u/dameyawn Jul 20 '16
Nice post again! The multiple assignment conditional looks so useful. Why do you caution against using it?
2
u/jrochkind Jul 21 '16
Nice. Regexp#named_captures is one I've been wondering why it's not there for years.
2
u/janko-m Jul 23 '16
The expand/collapse benchmark source feature is so awesome! And the whole post in general, I didn't know there were so many interesting things in Ruby 2.4.
1
u/Ark_Tane Jul 20 '16
Well that's embarassing. I would have sworn sum was already part of the standard library for enumerable. And I was so proud of my 10/10 on the Native Ruby vs. ActiveSupport quiz as well.
5
-7
1
u/senntenial Jul 21 '16
Awesome - they've covered nearly everything I wished was better :) - especially the report on error. That's great.
-1
21
u/Schrockwell Jul 20 '16
I love these posts, and also the design of this site. I learned a lot when 2.3 came out as well. Thanks for sharing, John.