Home Update Ruby steps towards frozen string literals

Ruby steps towards frozen string literals

35
pile of poorly sorted red ruby crystals


The subsequent model of the Ruby programming language, Ruby 3.4.0, has been launched in preview, bringing modifications for string literals and sophistication updates.

Unveiled May 16, the Ruby 3.4.Zero preview is downloadable from ruby-lang.org. With this replace, string literals in recordsdata with no frozen_string_literal remark now behave as in the event that they had been frozen. If mutated, a deprecation warning is emitted. The change marks a primary step towards making frozen string literals the default in Ruby. Frozen or immutable strings provide each efficiency and security benefits.

In different language modifications, key phrase splatting nil when calling strategies now could be supported, whereas block passing and key phrase arguments are not allowed in indexes.

Ruby 3.4.Zero additionally introduces two core class updates. First, Exception#set_backtrace now accepts arrays of Thread::Backtrace::Location, and Kernel#increase, Thread#increase, and Fiber#increase settle for this new format as effectively. Second, Range#measurement now raises SortError if the vary just isn’t iterable.

Error messages and backtrace shows have been modified to deal with compatibility points. Developers now can use a single quote as an alternative of a backtick as a gap quote. It can be now allowed to show a category identify earlier than a technique identify when the category has a everlasting identify.

In different enhancements, Array#every has been rewritten for higher efficiency. Passing a block to a technique that doesn’t use the handed block now will present a warning in verbose mode. And redefining some core strategies which are specifically optimized by the interpreter and JIT now will emit a efficiency class warning.

Ruby 3.4.Zero follows predecessors together with final month’s Ruby 3.2.4 launch, which introduced safety fixes, and the Christmas 2023 Ruby 3.3.Zero launch, which featured the Prism parser. Ruby itself dates again to a 1995 preliminary public launch.

Copyright © 2024 IDG Communications, Inc.



Source hyperlink

LEAVE A REPLY

Please enter your comment!
Please enter your name here