Skip to content

Commit 8cdfd11

Browse files
committed
Widen StringScanner#[] to accept named-capture String/Symbol keys
`StringScanner#[]` accepts a capture-group name as a String or Symbol in addition to an Integer index — the method's own RD doc in this file documents and demonstrates it ("`specifier` symbol or string. returns the named subgroup", with `scanner[:wday]` / `scanner['wday']` examples). The signature only listed `Integer`, so named-capture lookups type-check as an argument error.
1 parent fa84359 commit 8cdfd11

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

stdlib/strscan/0/string_scanner.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ class StringScanner
498498
# scanner[0] # => nil
499499
# scanner[1] # => nil
500500
#
501-
def []: (Integer) -> String?
501+
def []: (Integer | String | Symbol) -> String?
502502

503503
# <!--
504504
# rdoc-file=ext/strscan/strscan.c

0 commit comments

Comments
 (0)