diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-19 22:53:48 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-11-19 12:08:28 +0900 |
| commit | 610bcc88c2b4f3ca9bbfebb57279c25806fa0461 (patch) | |
| tree | 4f30e25db2aa9a923a080a08b87c6bc48766fc81 /mrblib | |
| parent | 698f5f707c2db334a15c605bf1b0d0cff42b1224 (diff) | |
| download | mruby-610bcc88c2b4f3ca9bbfebb57279c25806fa0461.tar.gz mruby-610bcc88c2b4f3ca9bbfebb57279c25806fa0461.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 6b61218ff..609883ecb 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 @@ -153,9 +149,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] } @@ -178,8 +173,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| |
