Friday 27 March 2020

Ruby 2.7 in Focal

The Ruby 2.7 transition is now complete and it is another new feature for users of the upcoming Ubuntu Focal Fossa release.

Ruby 2.7 is probably the last Ruby 2.x series release (the next one should be 3.0) and it comes with some nice features and improvements like: Pattern Matching, REPL improvement, Compaction GC, Separation of positional and keyword arguments and much more. To have a broad overview about the cool features and improvements check the Ruby 2.7 Release Announcement [1]. Below you can find some changes introduced by this new release.

Experimental features:

* Pattern matching
* Beginless range (i.e. array = [0,1,2,3,4,5]; p array[..2] #=> [0, 1, 2])

Features that emit warnings now and will become errors in the future:

* Using the last argument as keyword parameters
* Numbered parameters: '_1', '_2', and so on are reserved for numbered parameter
* Proc.new and Kernel#proc with no block in a method called with a block 
* Set special variables '$;' and '$,' to non-nil values
* 'yield' in singleton class syntax
* Access and setting of $SAFE, it will become a normal global variable in Ruby 3.0

Deprecated features, which will raise exceptions now:

* Kernel#lambda with no block in a method called with a block raises an exception
* Line break is prohibited as an identifier of the quote here document
* Dir.glob and Dir.[] no longer allow NUL-separated glob pattern. Use Array instead.

Moreover, some libraries are not bundled anymore in Ruby 2.7. If you need them please install them separately:

* CMath
* Scanf
* Shell
* Synchronizer (ruby-sync)
* ThreadsWait (ruby-thwait)
* E2MM (ruby-e2mmap)

For more information about Ruby 2.7 check the upstream documentation [2] (section Reference Documentation).


Enjoy it!