Project

General

Profile

Actions

Feature #19232

closed

add NoMatchingPatternError#matchee

Added by dalexj (alex jensen) almost 2 years ago. Updated almost 2 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:111277]

Description

currently if you pattern match a Hash, you can inspect the #key and #matchee methods from the NoMatchingPatternKeyError

begin
  { error: true } => { value: }
rescue NoMatchingPatternKeyError => e
  e.matchee
end
# => {:error=>true}

I would find it very helpful for this functionality to be available for the standard NoMatchingPatternError without hash key matching
proposed:

begin
  [:error, "message"] => [:ok, value]
rescue NoMatchingPatternError => e
  e.matchee
end
# => [:error, "message"]
Actions

Also available in: Atom PDF

Like0
Like0