File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ describe "Regex::MatchData" do
34
34
35
35
it " raises exception when named group doesn't exist" do
36
36
(" foo" =~ /foo/ ).should eq(0 )
37
- expect_raises(ArgumentError ) { $~ [" group" ] }
37
+ expect_raises(KeyError ) { $~ [" group" ] }
38
38
end
39
39
40
40
it " raises if outside match range with []" do
Original file line number Diff line number Diff line change @@ -148,16 +148,16 @@ class Regex
148
148
end
149
149
150
150
# Returns the match of the capture group named by *group_name*, or
151
- # raises an `ArgumentError ` if there is no such named capture group.
151
+ # raises an `KeyError ` if there is no such named capture group.
152
152
#
153
153
# ```
154
154
# "Crystal".match(/r(?<ok>ys)/).not_nil!["ok"] # => "ys"
155
- # "Crystal".match(/r(?<ok>ys)/).not_nil!["ng"] # raises ArgumentError
155
+ # "Crystal".match(/r(?<ok>ys)/).not_nil!["ng"] # raises KeyError
156
156
# ```
157
157
def [] (group_name : String )
158
158
match = self [group_name]?
159
159
unless match
160
- raise ArgumentError .new(" Match group named '#{ group_name } ' does not exist" )
160
+ raise KeyError .new(" Match group named '#{ group_name } ' does not exist" )
161
161
end
162
162
match
163
163
end
You can’t perform that action at this time.
0 commit comments