Issue #10123 has been updated by matz (Yukihiro Matsumoto).

Status changed from Open to Rejected

Implicit assignment from named capture is kind of confusing. Unless strongly persuaded, I am not going to enhance the feature.
Although we have no plan to remove the feature.

Matz.

----------------------------------------
Feature #10123: Named capture groups don't set local vars when matched using ~
https://bugs.ruby-lang.org/issues/10123#change-81348

* Author: josh.cheek (Josh Cheek)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>