diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-04-01 14:21:40 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-04-01 14:21:40 +0900 |
| commit | cf58d0d3e9ca12a922b452473427bcf66598fae3 (patch) | |
| tree | 59a34cd6867087dcf6da1410d748f55e5497c3ce /mrblib | |
| parent | f05069fd1a80c0fd46f92a7763ba0dbcab0feebc (diff) | |
| download | mruby-cf58d0d3e9ca12a922b452473427bcf66598fae3.tar.gz mruby-cf58d0d3e9ca12a922b452473427bcf66598fae3.zip | |
move Hash#inspect implementation to mrblib/hash.rb
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/hash.rb | 12 |
1 files changed, 12 insertions, 0 deletions
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? |
