Posted by naruse on 25 Dec 2017

We are pleased to announce the release of Ruby 2.5.0.

Ruby 2.5.0 is the first stable release of the Ruby 2.5 series. It introduces many new features and performance improvements. The notable changes are as follows:

New Features

rescue / else / ensure are now allowed to be used directly with do / end blocks. [Feature #12906]

/ / are now allowed to be used directly with / blocks. [Feature #12906] Add yield_self to yield given block in its context. Unlike tap , it returns the result of the block. [Feature #6721]

to yield given block in its context. Unlike , it returns the result of the block. [Feature #6721] Support branch coverage and method coverage measurement. The branch coverage indicates which branches are executed and which are not. The method coverage indicates which methods are invoked and which are not. By running a test suite with these new features, you will know which branches and methods are executed, and evaluate total coverage of the test suite more strictly. [Feature #13901]

Hash#slice [Feature #8499] and Hash#transform_keys [Feature #13583]

Struct.new can create classes that accept keyword arguments. [Feature #11925]

Enumerable#any?, all?, none?, and one? accept a pattern argument. [Feature #11286]

Top-level constant look-up is no longer available. [Feature #11547]

One of our most loved libraries, pp.rb, is now automatically loaded. You no longer have to write require "pp" . [Feature #14123]

. [Feature #14123] Print backtrace and error message in reverse order (oldest call first, most recent call last). When a long backtrace appears on your terminal (TTY), you can easily find the cause line at the bottom of the backtrace. Note that the order is reversed only when the backtrace is printed out to the terminal directly. [Feature #8661] [experimental]

Performance improvements

About 5-10% performance improvement by removing all trace instructions from overall bytecode (instruction sequences). The trace instruction was added to support the TracePoint . However, in most cases, TracePoint is not used and trace instructions are pure overhead. Instead, now we use a dynamic instrumentation technique. See [Feature #14104] for more details.

instructions from overall bytecode (instruction sequences). The instruction was added to support the . However, in most cases, is not used and instructions are pure overhead. Instead, now we use a dynamic instrumentation technique. See [Feature #14104] for more details. Block passing by a block parameter (e.g. def foo(&b); bar(&b); end ) is about 3 times faster than Ruby 2.4 by “Lazy Proc allocation” technique. [Feature #14045]

) is about 3 times faster than Ruby 2.4 by “Lazy Proc allocation” technique. [Feature #14045] Mutex is rewritten to be smaller and faster. [Feature #13517]

ERB now generates code from a template twice as fast as Ruby 2.4.

Improve performance of some built-in methods including Array#concat , Enumerable#sort_by , String#concat , String#index , Time#+ , and more.

, , , , , and more. IO.copy_stream uses copy_file_range(2) to copy offload. [Feature #13867]

Other notable changes since 2.4

See NEWS or the commit logs for details.

With those changes, 6158 files changed, 348484 insertions(+), 82747 deletions(-) since Ruby 2.4.0!

Merry Christmas, Happy Holidays, and enjoy programming with Ruby 2.5!

Download