From: matz@... Date: 2019-09-02T06:39:37+00:00 Subject: [ruby-core:94732] [Ruby master Feature#10123] Named capture groups don't set local vars when matched using ~ 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 '~/(?\w)/ and puts initial' -e:1:in `
': undefined local variable or method `initial' for main:Object (NameError) ~~~ Working when using `=~ $_`: ~~~ $ echo ' josh' | ruby -ne '/(?\w)/ =~ $_ and puts initial' j ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: