Project

General

Profile

Actions

Feature #10123

closed

Named capture groups don't set local vars when matched using ~

Added by josh.cheek (Josh Cheek) over 10 years ago. Updated about 5 years ago.

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

Description

Broken when using ~:

$ echo ' josh' | ruby -ne '~/(?<initial>\w)/ and puts initial'
-e:1:in `<main>': undefined local variable or method `initial' for main:Object (NameError)

Working when using =~ $_:

$ echo ' josh' | ruby -ne '/(?<initial>\w)/ =~ $_ and puts initial'
j
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0