diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-19 21:54:32 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-19 22:02:46 +0900 |
| commit | 6d1728822d575812cbc0c5c3e181ac0031a75914 (patch) | |
| tree | 7ef1ac2a274bf05586bcde2300514c6505483341 | |
| parent | e207d5af43e9d6e09679e9aee9bf00a843528e0e (diff) | |
| download | mruby-6d1728822d575812cbc0c5c3e181ac0031a75914.tar.gz mruby-6d1728822d575812cbc0c5c3e181ac0031a75914.zip | |
Removed `String#try_convert` method from `mruby-string-ext` gem.
Because `try_convert` method rarely used in production. For mruby users,
we have `__to_str` utility method to check string type.
| -rw-r--r-- | mrbgems/mruby-string-ext/mrblib/string.rb | 19 | ||||
| -rw-r--r-- | mrbgems/mruby-string-ext/test/string.rb | 7 |
2 files changed, 0 insertions, 26 deletions
diff --git a/mrbgems/mruby-string-ext/mrblib/string.rb b/mrbgems/mruby-string-ext/mrblib/string.rb index 9212d83a5..2a323c858 100644 --- a/mrbgems/mruby-string-ext/mrblib/string.rb +++ b/mrbgems/mruby-string-ext/mrblib/string.rb @@ -1,25 +1,6 @@ class String ## - # call-seq: - # String.try_convert(obj) -> string or nil - # - # Try to convert <i>obj</i> into a String, using to_str method. - # Returns converted string or nil if <i>obj</i> cannot be converted - # for any reason. - # - # String.try_convert("str") #=> "str" - # String.try_convert(/re/) #=> nil - # - def self.try_convert(obj) - if self === obj - obj - else - nil - end - end - - ## # call-seq: # string.clear -> string # diff --git a/mrbgems/mruby-string-ext/test/string.rb b/mrbgems/mruby-string-ext/test/string.rb index 024b2cd4b..b44e8181a 100644 --- a/mrbgems/mruby-string-ext/test/string.rb +++ b/mrbgems/mruby-string-ext/test/string.rb @@ -4,13 +4,6 @@ UTF8STRING = ("\343\201\202".size == 1) -assert('String.try_convert') do - assert_nil String.try_convert(nil) - assert_nil String.try_convert(:foo) - assert_equal "", String.try_convert("") - assert_equal "1,2,3", String.try_convert("1,2,3") -end - assert('String#getbyte') do str1 = "hello" bytes1 = [104, 101, 108, 108, 111] |
