mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
string type check based on #to_str to encourage duck typing; #1616
This commit is contained in:
+1
-1
@@ -137,7 +137,7 @@ class String
|
||||
##
|
||||
# ISO 15.2.10.5.5
|
||||
def =~(re)
|
||||
if re.is_a? String
|
||||
if re.respond_to? :to_str
|
||||
raise TypeError, "type mismatch: String given"
|
||||
end
|
||||
re =~ self
|
||||
|
||||
Reference in New Issue
Block a user