From cf58d0d3e9ca12a922b452473427bcf66598fae3 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 1 Apr 2014 14:21:40 +0900 Subject: move Hash#inspect implementation to mrblib/hash.rb --- mrblib/hash.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mrblib') diff --git a/mrblib/hash.rb b/mrblib/hash.rb index d24fce849..74d3d0534 100644 --- a/mrblib/hash.rb +++ b/mrblib/hash.rb @@ -132,6 +132,18 @@ class Hash h end + ## + # Return the contents of this hash as a string. + # + # ISO 15.2.13.4.30 (x) + def inspect + return "{}" if self.size == 0 + "{"+self.map {|k,v| + k.inspect + "=>" + v.inspect + }.join(", ")+"}" + end + alias to_s inspect + # 1.8/1.9 Hash#reject! returns Hash; ISO says nothing. def reject!(&b) return to_enum :reject! unless block_given? -- cgit v1.2.3