diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-19 22:53:48 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-19 22:53:48 +0900 |
| commit | cb85fa6787ea9467f81be41570a36b475b7ef061 (patch) | |
| tree | 0f75fd9dbe38a0700dc47963d0900aaafc5ea031 /mrblib | |
| parent | b4a35344a67812510a34f93f9d6b8400a2183432 (diff) | |
| download | mruby-cb85fa6787ea9467f81be41570a36b475b7ef061.tar.gz mruby-cb85fa6787ea9467f81be41570a36b475b7ef061.zip | |
Removed `to_hash` conversion method.
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/hash.rb | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/mrblib/hash.rb b/mrblib/hash.rb index 96029a230..1cd039c45 100644 --- a/mrblib/hash.rb +++ b/mrblib/hash.rb @@ -12,9 +12,7 @@ class Hash # ISO 15.2.13.4.1 def ==(hash) return true if self.equal?(hash) - begin - hash = hash.to_hash - rescue NoMethodError + unless Hash === hash return false end return false if self.size != hash.size @@ -32,9 +30,7 @@ class Hash # ISO 15.2.13.4.32 (x) def eql?(hash) return true if self.equal?(hash) - begin - hash = hash.to_hash - rescue NoMethodError + unless Hash === hash return false end return false if self.size != hash.size @@ -154,9 +150,8 @@ class Hash # # ISO 15.2.13.4.23 def replace(hash) - raise TypeError, "can't convert argument into Hash" unless hash.respond_to?(:to_hash) + raise TypeError, "Hash required (#{hash.class} given)" unless Hash === hash self.clear - hash = hash.to_hash hash.each_key{|k| self[k] = hash[k] } @@ -179,8 +174,7 @@ class Hash # # ISO 15.2.13.4.22 def merge(other, &block) - raise TypeError, "can't convert argument into Hash" unless other.respond_to?(:to_hash) - other = other.to_hash + raise TypeError, "Hash required (#{other.class} given)" unless Hash === other h = self.dup if block other.each_key{|k| |
