このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

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

singleton method NoMatchingPatternKeyError.new

new(message = nil, matchee: nil, key: nil) -> NoMatchingPatternKeyErrorRuby 3.1 から[permalink][rdoc][edit]

例外オブジェクトを生成して返します。

[PARAM] message:
エラーメッセージを表す文字列です。
[PARAM] matchee:
パターンマッチの対象となったオブジェクトです。 NoMatchingPatternKeyError#matchee で取り出せます。
[PARAM] key:
見つからなかったキーです。 NoMatchingPatternKeyError#key で取り出せます。
data = {name: "ken"}
e = NoMatchingPatternKeyError.new("key not found", matchee: data, key: :age)
p e.matchee.equal?(data) # => true
p e.key                  # => :age