Actions
Bug #21040
closedString#next! method does not mutate $& variable
Bug #21040:
String#next! method does not mutate $& variable
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [arm64-darwin24]
Description
String#next! method should mutate string and return mutated version. For some reason, using it on $& does not mutate it but still returns new version.
Steps to reproduce (2 different ways):
Updated by Eregon (Benoit Daloze) over 1 year ago
Updated by Hanmac (Hans Mackowiak) over 1 year ago
These are called virtual variables, a new object is created each time you try to access it
rb_define_virtual_variable("$~", get_LAST_MATCH_INFO, match_setter);
rb_define_virtual_variable("$&", last_match_getter, 0);
rb_define_virtual_variable("$`", prematch_getter, 0);
rb_define_virtual_variable("$'", postmatch_getter, 0);
rb_define_virtual_variable("$+", last_paren_match_getter, 0);
in ruby this is the result:
Actions