Ruby 2.3

by Leo Royzengurt

December 17, 2015

Ruby 2.3 is coming out on December 25th so we will all have something fun to play with in between eggnog and unwrapping presents! Ruby 2.3preview2 has been released already and we have had a chance to look over the features and play around with it a bit. Here are some of our favorite features!

Frozen String Literal Pragma 

String literals will no longer be allowed to be modified in run time. While this has already been an opt-in feature it will now be set as default for string literals, so trying to change parts of a string literal will no longer be available. Instead, if an action occurs that tries to change the value of a string literal the "can't modify frozen String" error will occur in your console. 

Safe Navigation Operator 

One of the features we are most excited for, since we work heavily with Devise, is the new safe navigation operator. We became familiar with it in our deep dive in swift; it will allow for us to chain querys safely and avoid raising errors. 

### Ruby 2.2
if current_user && current_user.has_store?
# run

### Ruby 2.3

if current_user&.has_store?
# run

It will be interesting to triple chain these methods for cleaner faster code! This method is similar to the .try(:value) method that can be chained as well. 

The did_you_mean_gem is now bundled

This gem is amazing for apps where models have tons of attributes and methods. Let's say you misspell referrer with referer the app will display a method name suggestion  in the console.



# => NoMethodError: undefined method `referer' for #Store

#Did you mean? #referrer