Ruby 2.3.0 Highlights

Newest version of Ruby due on Christmas

Posted on December 2, 2015

I’ve been watching some great RubyConf talks recently, and Matz (creator of Ruby) is always fun to watch. He went over some new features in Ruby 2.3.0, so I thought I’d re-report them here for everyone. This is the talk I got them from.


grep is a Unix command for pattern matching. For example, if I wanted to check my history for a recent ssh IP address, I could try something like:

history |grep ssh

So grep -v is the inverse - you’ll get all the results that don’t match. I am imagining it is used like so:

["", "", ""].grep_v /.+gmail.+/ 
#=> [""]


Stricter version of Hash#values_at. Check out the feature request here.

Numeric#positive? Numeric#negative?

Longer than > 0 !

Hash comparisons: <=, <, >=, >

This seems odd, but it A >= B is another way of asking if hash A contain all of B and possibly more.


Here’s an example straight from the talk:

h = { 1: 2, 2: 4, 3: 6 }
#=> [2, 4, 6]


Just a ruby interpreter helper for typos on methods. Doesn’t seem very useful to me.

Frozen string crap

Strings will be frozen by default I think. This frees up space or something. Feels inconvenient, so I hope the gains are worth it!

Safe navigation with &.

Look, it’s a guy sitting on the floor staring at a dot! The ‘lonely operator’! This one is really useful:

# instead of this to avoid pesky nils
u = User.find("Matz")
u && &&

# you can do this now


Array, Hash#dig

This is also another very useful feature in Ruby 2.3. It’s unsafe to check arrays or hashes at depth for values if you aren’t sure they’ll be there, because you’ll get an error once a nil comes up. Now, there’s a safe dig method available, and it’s not unsimilar to the aforementioned &.:

# instead of this risky query

# now we can
data.dig(:users, 0, :name)

Another really common need, at least for me, is the opposite of this dig which I’m calling bury. I actually tweeted to @Matz about this feature request and posted to the Ruby lang redmine forum thing. bury allows you to insert an object at an arbitrary depth into an array or hash:

data.bury(:users, 0, :name, 'Matz') # This is not part of Ruby!!

My feature request actually got a few comments!