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:
-
Updated by nobu (Nobuyoshi Nakada) almost 12 years ago
- Description updated (diff)
I'm not sure if this should be a bug or a new feature.
Updated by josh.cheek (Josh Cheek) over 10 years ago
Updated by jeremyevans0 (Jeremy Evans) almost 7 years ago
- Tracker changed from Bug to Feature
- ruby -v deleted (
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]) - Backport deleted (
2.0.0: UNKNOWN, 2.1: UNKNOWN)
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.
Updated by matz (Yukihiro Matsumoto) almost 7 years ago
- 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.
Actions