Project

General

Profile

Actions

Feature #19232

closed

add NoMatchingPatternError#matchee

Added by dalexj (alex jensen) over 1 year ago. Updated over 1 year 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"]

Updated by ktsj (Kazuki Tsujimoto) over 1 year ago

  • Status changed from Open to Feedback

Do you have any real use case for this?

Actions

Also available in: Atom PDF

Like0
Like0