From 5bbcea9b3bdb0e7dc048f92cebefb54858196935 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 19 Sep 2018 22:01:28 +0900 Subject: Removed `try_convert` method from Array and Hash. --- mrbgems/mruby-hash-ext/mrblib/hash.rb | 19 ------------------- mrbgems/mruby-hash-ext/test/hash.rb | 6 ------ 2 files changed, 25 deletions(-) (limited to 'mrbgems/mruby-hash-ext') diff --git a/mrbgems/mruby-hash-ext/mrblib/hash.rb b/mrbgems/mruby-hash-ext/mrblib/hash.rb index 5bbbdf559..f1143e25b 100644 --- a/mrbgems/mruby-hash-ext/mrblib/hash.rb +++ b/mrbgems/mruby-hash-ext/mrblib/hash.rb @@ -60,25 +60,6 @@ class Hash h end - ## - # call-seq: - # Hash.try_convert(obj) -> hash or nil - # - # Try to convert obj into a hash, using to_hash method. - # Returns converted hash or nil if obj cannot be converted - # for any reason. - # - # Hash.try_convert({1=>2}) # => {1=>2} - # Hash.try_convert("1=>2") # => nil - # - def self.try_convert(obj) - if obj.respond_to?(:to_hash) - obj.to_hash - else - nil - end - end - ## # call-seq: # hsh.merge!(other_hash) -> hsh diff --git a/mrbgems/mruby-hash-ext/test/hash.rb b/mrbgems/mruby-hash-ext/test/hash.rb index 269da800d..b5d0aaaf8 100644 --- a/mrbgems/mruby-hash-ext/test/hash.rb +++ b/mrbgems/mruby-hash-ext/test/hash.rb @@ -45,12 +45,6 @@ assert('Hash.[] for sub class') do assert_equal(sub_hash_class, sub_hash.class) end -assert('Hash.try_convert') do - assert_nil Hash.try_convert(nil) - assert_nil Hash.try_convert("{1=>2}") - assert_equal({1=>2}, Hash.try_convert({1=>2})) -end - assert('Hash#merge!') do a = { 'abc_key' => 'abc_value', 'cba_key' => 'cba_value' } b = { 'cba_key' => 'XXX', 'xyz_key' => 'xyz_value' } -- cgit v1.2.3