|
1 | 1 | --- |
2 | 2 | title: Ruby 3.1 changes |
3 | | -prev: / |
4 | | -next: 3.0 |
| 3 | +prev: 3.2 |
| 4 | +next: 3.1 |
5 | 5 | description: Ruby 3.1 full and annotated changelog |
6 | 6 | --- |
7 | 7 |
|
8 | 8 | # Ruby 3.1 |
9 | 9 |
|
10 | 10 | * **Released at:** Dec 25, 2021 (<a class="github" href="https://github.com/ruby/ruby/blob/ruby_3_1/NEWS.md">NEWS.md</a> file) |
11 | | -* **Status (as of Jul 09, 2022):** 3.1.2 is current _stable_ |
| 11 | +* **Status (as of Feb 04, 2023):** 3.1.3 is current _stable_ |
12 | 12 | * **This document first published:** Jan 5, 2022 |
13 | | -* **Last change to this document:** Jul 09, 2022 |
| 13 | +* **Last change to this document:** Feb 04, 2023 |
14 | 14 |
|
15 | 15 | > **Note:** As already explained in [Introduction](README.md), this site is dedicated to changes in the **language**, not the **implementation**, therefore the list below lacks mentions of lots of important optimization introduced in 3.1, including a new JIT named YJIT. That's not because they are not important, just because this site's goals are different. |
16 | 16 |
|
@@ -106,7 +106,7 @@ In hash literals and method calls, `x:` is now a shortcut for `x: x`—take hash |
106 | 106 |
|
107 | 107 | If method uses its block argument only to pass to another method, it can be marked by anonymous `&`. |
108 | 108 |
|
109 | | -* **Reason:** The initial proposal for the feature is 6-year old and focused on avoiding intermediate blocks object allocation on block forwarding. It was considered redundant when block forwarding was optimized in Ruby 2.5; but then the core team decided it is actually a nice and unambiguous shortcut for methods that just pass the block further. As bloc argument is frequently called just `block`, the absence of the name doesn't affect readability. |
| 109 | +* **Reason:** The initial proposal for the feature is 6-year old and focused on avoiding intermediate blocks object allocation on block forwarding. It was considered redundant when block forwarding was optimized in Ruby 2.5; but then the core team decided it is actually a nice and unambiguous shortcut for methods that just pass the block further. As block argument is frequently called just `block`, the absence of the name doesn't affect readability. |
110 | 110 | * **Discussion:** <a class="tracker feature" href="https://bugs.ruby-lang.org/issues/11256">Feature #11256</a> |
111 | 111 | * **Documentation:** <a class="ruby-doc" href="https://docs.ruby-lang.org/en/3.1/syntax/methods_rdoc.html#label-Block+Argument">doc/syntax/methods.rdoc#Block Argument</a> |
112 | 112 | * **Code:** |
@@ -333,6 +333,7 @@ The class of the context (`self`) available inside the `refine SomeClass do ... |
333 | 333 | end |
334 | 334 | end |
335 | 335 | ``` |
| 336 | +* **Follow-ups:** In Ruby 3.2, several usability improvments using the new class [were introduced](3.2.html#refinements): ability to ask which refinements some module defines, which refinements are active in the current context, and what class or module the particular refinement refines. |
336 | 337 |
|
337 | 338 | #### `Module#prepend` behavior change[](#moduleprepend-behavior-change) |
338 | 339 |
|
@@ -442,6 +443,7 @@ Now, when module is prepended to the class, it always becomes first in the ances |
442 | 443 | # => true |
443 | 444 | ``` |
444 | 445 | * **Notes:** Another idea discussed was just having `Method#visibility`, but it was hard to decide on the method's name and what it should return, while three predicates are more or less obvious. |
| 446 | +* **Follow-up:** [Reverted](3.2.html#methodpublic-protected-and-private-are-removed) in Ruby 3.2: it was considered after all that visibility is not a property of the method, but rather the responsibility of its owner. |
445 | 447 |
|
446 | 448 | ### `Kernel#load`: module as a second argument[](#kernelload-module-as-a-second-argument) |
447 | 449 |
|
@@ -729,6 +731,7 @@ The new parameter is accepting offsets or timezone objects, and (finally!) allow |
729 | 731 | #=> #<struct Locale lang=:ua, translations={:user=>"користувач", :application=>"застосунок"}> |
730 | 732 | # ...no braces necessary, no warning |
731 | 733 | ``` |
| 734 | +* **Follow-up:** Since 3.2, following the warning, the structs [can be initialized](3.2.html#struct-can-be-initialized-by-keyword-arguments-by-default) by both keyword and positional argument when `keyword_init: true` is not defined. |
732 | 735 |
|
733 | 736 | #### `StructClass#keyword_init?`[](#structclasskeyword_init) |
734 | 737 |
|
@@ -895,8 +898,6 @@ A new class representing low-level I/O abstraction. Internally, uses OS mechanis |
895 | 898 | * **Discussion:** <a class="tracker feature" href="https://bugs.ruby-lang.org/issues/18020">Feature #18020</a> |
896 | 899 | * **Documentation:** <a class="ruby-doc" href="https://docs.ruby-lang.org/en/3.1/IO/Buffer.html"><code>IO::Buffer</code></a> |
897 | 900 | * **Code:** _This is a big new class, see class' docs for detailed examples of usage, they are quite succinct._ |
898 | | -* **Notes:** |
899 | | -* **Follow-up:** |
900 | 901 |
|
901 | 902 | ### `File.dirname`: optional `level` to go up the directory tree[](#filedirname-optional-level-to-go-up-the-directory-tree) |
902 | 903 |
|
|
0 commit comments