Actions
Feature #10123
closedNamed capture groups don't set local vars when matched using ~
Feature #10123:
Named capture groups don't set local vars when matched using ~
Status:
Rejected
Assignee:
-
Target version:
-
Actions
Added by josh.cheek (Josh Cheek) almost 12 years ago. Updated almost 7 years ago.
I'm not sure if this should be a bug or a new feature.
Looking at the documentation for Regexp#=~ as well as the Capture section of the Regexp class documentation, both of which describe assignment of named captures to local variables, it seems intentional that only the /(?<some>re)/ =~ string case sets local variables. Even the string =~ /(?<some>re)/ case does not set them. So I think this should be considered a feature request.
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.