[ruby-core:94732] [Ruby master Feature#10123] Named capture groups don't set local vars when matched using ~

[email protected]
Newsgroups gmane.comp.lang.ruby.core
Message-ID <redmine.journal-81348.20190902063937.6f370d870ef2889a@ruby-lang.org>
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:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.