diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-19 21:51:53 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-19 22:01:59 +0900 |
| commit | e207d5af43e9d6e09679e9aee9bf00a843528e0e (patch) | |
| tree | 7f83038d199fc076b316d51654819ef6bad5fa78 /mrbgems/mruby-string-ext/mrblib | |
| parent | c09d250ca148c0efc0167d55885bd20da87b43f7 (diff) | |
| download | mruby-e207d5af43e9d6e09679e9aee9bf00a843528e0e.tar.gz mruby-e207d5af43e9d6e09679e9aee9bf00a843528e0e.zip | |
Remove implicit conversion using `to_str` method.
We have added internal convenience method `__to_str` which
does string type check.
Diffstat (limited to 'mrbgems/mruby-string-ext/mrblib')
| -rw-r--r-- | mrbgems/mruby-string-ext/mrblib/string.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/mrbgems/mruby-string-ext/mrblib/string.rb b/mrbgems/mruby-string-ext/mrblib/string.rb index 27ca30610..9212d83a5 100644 --- a/mrbgems/mruby-string-ext/mrblib/string.rb +++ b/mrbgems/mruby-string-ext/mrblib/string.rb @@ -12,8 +12,8 @@ class String # String.try_convert(/re/) #=> nil # def self.try_convert(obj) - if obj.respond_to?(:to_str) - obj.to_str + if self === obj + obj else nil end @@ -142,7 +142,7 @@ class String # "abcdef".casecmp("ABCDEF") #=> 0 # def casecmp(str) - self.downcase <=> str.to_str.downcase + self.downcase <=> str.__to_str.downcase rescue NoMethodError nil end |
