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. 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 (section Reference Documentation).

Enjoy it!

1 Like