Project

General

Profile

Actions

Feature #11429

open

Local variable assignment via regex ===

Added by seanlinsley (Sean Linsley) about 9 years ago. Updated about 9 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:70318]

Description

Currently, this assigns the username variable:

/(?<username>.*)@.*\..*/ =~ "seanlinsley@example.com"

But this does not:

/(?<username>.*)@.*\..*/ === "seanlinsley@example.com"

If it did, it would be possible to set variables during a case statement, which was my original goal:

case "seanlinsley@example.com"
when /(?<username>.*)@.*\..*/
  puts "Username is: #{username}"
end

I would be happy to implement this, if it's a desired feature.

Updated by seanlinsley (Sean Linsley) about 9 years ago

  • Subject changed from Local variable assignment Regex via === to Local variable assignment via regex ===

Updated by nobu (Nobuyoshi Nakada) about 9 years ago

  • Description updated (diff)

They are different stories.

Enabling assignment via Regexp#=== doesn't mean it via when.

Actions

Also available in: Atom PDF

Like0
Like0Like0