Ruby 4.1 リファレンスマニュアル

NEWS for Ruby 2.7.0

[edit]

このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。十分な情報と共に書かれた全ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。

2.6.0 以降の変更

言語仕様の変更

パターンマッチ

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: age}]}
#=> NoMatchingPatternError

3.0 に向けてのキーワード引数の仕様変更

番号指定パラメータ

ブロックなしの proc/lambda が deprecated

その他の変更

コマンドラインオプション

警告オプション

カテゴリ化された警告を管理するために「-W」オプションが「:」を続けられるように拡張されました。 [feature#16345] [feature#16420]

組み込みクラスの更新のWarningも参照してください。

組み込みクラスの更新 (注目すべきもののみ)

Enumerable#tally
p ["A", "B", "C", "B", "A"].tally #=> {"A"=>2, "B"=>2, "C"=>1}
Enumerator::Lazy#eager
a = %w(foo bar baz)
e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
p e.class               #=> Enumerator
p e.map {|x| x + "?" }  #=> ["FOO!?", "BAR!?", "BAZ!?"]
Enumerator::Lazy#with_index
("a"..).lazy.with_index(1) { |it, index| puts "#{index}:#{it}" }.take(3).force
# => 1:a
#    2:b
#    3:c

標準添付ライブラリの更新 (注目すべきもののみ)

$ ruby test.rb --baa
Traceback (most recent call last):
test.rb:7:in `<main>': invalid option: --baa (OptionParser::InvalidOption)
Did you mean?  baz
               bar

互換性 (機能追加とバグ修正を除く)

標準添付ライブラリの互換性 (機能追加とバグ修正を除く)

C API の更新

実装の改善

その他の変更