Ruby 2.7 Released, introducing pattern matching

December 25, Ruby development team released Ruby 2.7.0, the latest stable release. It experimentally introduces pattern matching, and there are notable performance improvements.

Ruby 2.7 is the latest version following v2.6 released on December 25, 2018. Most notable is the experimental introduction of pattern matching, and newly added Compaction GC.

Experimentally introduced Pattern Matching is a format feature. If a pattern and how to handle it are described, this format feature can execute the handling of the pattern when a given object matches the description of the pattern. It can assign value, variable, hash, and array.

Compaction GC is a feature that defragments the fragmented memory space. It deals with the memory fragmentation problem that occurs in some multi-threaded Ruby programs. It uses the GC.compact method, which compacts a heap, to perform compaction on live objects in a heap so that less pages are used. Now heap is expected to have better compatibility with CoW (Copy on Write).

There are other notable improvements such as the separation of keyword arguments and positional arguments, and REPL improvement. Due to the changes in JIT-related experimental feature and Fiber’s cache strategy, the performance has improved. Also various standard libraries have been updated.