Short Bytes: Ruby development team has released Ruby 2.3.0 – the first stable release of Ruby 2.3 series. It comes with improvements like Frozen String Literal Pragma, Safe navigation operator, the did_you_mean gem, and more. Read more to know about these changes in detail.
Just a few days ago, Ruby development team announced the release of Ruby 2.3.0. This is the first stable release of Ruby 2.3 series.
What Are The New Features in Ruby 2.3.0?
Frozen String Literal Pragma:
Now string literals can be frozen and marked as immutable using this syntax:
CONSTANT_STRING = 'constant string'.freeze
This feature will allow a developer to improve the performance as Ruby will need to allocate fewer objects. To freeze all string literals in source files, a new magic command has been introduced:
# frozen_string_literal: true
Safe Navigation Operator / Lonely Operator:
Already present in Swift, C#, and Groovy, &. operator allows nil handling easier. If the object equals nil, it will return nil. In any other case, it’ll call the method on the object.
Find your dream job
The did_you_mean gem:
The did_you_mean gem allows your to detect any typos to make the debugging process easier. This small change will prove working with the language more easy, particularly for new programmers.
"Yuki".starts_with?("Y") # => NoMethodError: undefined method `starts_with?' for "Yuki":String # Did you mean? start_with?
Other changes in Ruby 2.3.0:
The other important changes include:
- Hash Comparison
- Hash#dig and Array#dig
- Number #negative? and #positive?
Find the download links and read more about the release on Ruby’s website.
Get 92% off on Ruby On Rails Bundle at fossBytes store.