Ruby 2.3 Released
Ruby 2.3 Released
Written by Kay Ewbank   
Friday, 01 January 2016

Ruby 2.3 has been released for the New Year packed with new features. 

This is the first stable release of Ruby 2.3 series, and among the new features, the frozen string literal pragma is perhaps the most obvious.

 

rubylogo

Versions of Ruby up to 2.2 had mutable strings by default, If you wanted to make a string immutable, you had to call #freeze on it. 

Immutable or frozen strings improve the overall performance because Ruby had to allocate fewer objects. In recognition of this, there are plans to make strings immutable by default in Ruby 3.0. 

The new release provides an interim solution by having the option for all string literals to be frozen by default. All you have to do is to add a command line option or the magic comment:

#frozen_string_literal: true

at the start of the file. This will ensure that all the string literals in the file are frozen without having to call #freeze on them. If you're unfamiliar with magic comments, they're preprocessing directives that the source code interpreter read to set the appropriate encoding before processing your source code.

Another addition to the new language version is a safe navigation operator, also known as a lonely operator. The &. operator already exists in C#, Groovy, and Swift, and in Ruby will make it easier to handle nils. One use is when you need to check if an object is nil before calling a method on it. It will return nil if the object equals nil, otherwise it calls the method on the object. Array#dig and Hash#dig have also been added, providing a simpler API for accessing nested elements in arrays and hashes.

One useful improvement is the bundling of did_you_mean gem. If you get a "NoMethodError" because you've typed the method name incorrectly, Ruby will now suggest other method names similar to whatever you've mistyped.

The new version also has a number of performance improvements, including machine code level tuning for object allocation and method calling code, a smarter instance variable data structure,a reconsider method entry data structure, and an introducing new table data structure. The full list can be seen in the release notes. 

 

 rubylogo

 

More Information

Ruby Language

Download Ruby

Related Articles

Ruby And Rails Updated

Ruby 2.1 With Better Garbage Collection

To be informed about new articles on I Programmer, sign up for our weekly newsletter,subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin

Banner


Earthquake Prediction Using Machine Learning
05/09/2017

Machine Learning is good it identifying signals that human observers might not notice. Researchers at Los Alamos have used it with a laboratory-created earthquake simulation to predict the time remain [ ... ]



Java API for RESTful Web Services 2.1 Released
29/08/2017

JAX-RS 2.1 Java API for RESTful Web Services  has been released with support for server-sent events, JSON-B and improved support for JSON-P.


More News

 
 

 

blog comments powered by Disqus

Last Updated ( Thursday, 31 December 2015 )
 
 

   
RSS feed of news items only
I Programmer News
Copyright © 2017 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.