diff options
| author | Ichito Nagata <[email protected]> | 2018-06-04 10:52:51 +0900 |
|---|---|---|
| committer | Ichito Nagata <[email protected]> | 2018-06-04 11:25:10 +0900 |
| commit | 2af92d0ebcbeca6d3d85a27c8193273080a63090 (patch) | |
| tree | 51213df1520495df867610f6a84e5d47547bc1bb /mrblib/array.rb | |
| parent | 395260747add350d55eab002c183e7028605dbc8 (diff) | |
| download | mruby-2af92d0ebcbeca6d3d85a27c8193273080a63090.tar.gz mruby-2af92d0ebcbeca6d3d85a27c8193273080a63090.zip | |
Let inspect recursion do the right thing
Diffstat (limited to 'mrblib/array.rb')
| -rw-r--r-- | mrblib/array.rb | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/mrblib/array.rb b/mrblib/array.rb index 334f4e984..bc9a2a492 100644 --- a/mrblib/array.rb +++ b/mrblib/array.rb @@ -83,20 +83,18 @@ class Array self end - def _inspect + def _inspect(recur_list) return "[]" if self.size == 0 - "["+self.map{|x|x.inspect}.join(", ")+"]" + return "[...]" if recur_list[self.object_id] + recur_list[self.object_id] = true + "["+self.map{|x|x._inspect(recur_list)}.join(", ")+"]" end ## # Return the contents of this array as a string. # # ISO 15.2.12.5.31 (x) def inspect - begin - self._inspect - rescue SystemStackError - "[...]" - end + self._inspect({}) end # ISO 15.2.12.5.32 (x) alias to_s inspect |
