Project

General

Profile

Actions

Feature #16796

closed

Assigning local variables when using `case when regexp`

Added by UlyssesZhan (Ulysses Zhan) about 4 years ago. Updated over 1 year ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:97935]

Description

I want to use

case "str"
when /s(?<mid>.)r/
  p mid
end

instead of

case
when /s(?<mid>.)r/ =~ "str"
  p mid
end

I also do not like using $1.

This feature is extremely useful when there are a lot of whens.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0