NEWS for Ruby 2.7.0¶ ↑
This document is a list of user visible feature changes made between releases except for bug fixes.
Note that each entry is kept so brief that no reason behind or reference information is supplied with. For a full list of changes with all sufficient information, see the ChangeLog file or Redmine (e.g. https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER).
Changes since the 2.6.0 release¶ ↑
Language changes¶ ↑
Pattern matching¶ ↑
-
Pattern matching is introduced as an experimental feature. [Feature #14912]
case [0, [1, 2, 3]] in [a, [b, *c]] p a #=> 0 p b #=> 1 p c #=> [2, 3] end case {a: 0, b: 1} in {a: 0, x: 1} :unreachable in {a: 0, b: var} p var #=> 1 end case -1 in 0 then :unreachable in 1 then :unreachable end #=> NoMatchingPatternError json = <<END { "name": "Alice", "age": 30, "children": [{ "name": "Bob", "age": 2 }] } END JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: name, age: age}]} p name #=> "Bob" p age #=> 2 JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: "Charlie", age: