diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-07-17 10:35:59 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-07-17 10:35:59 +0900 |
| commit | 5eef75b678b41249cf4738ef42889090caea2ab0 (patch) | |
| tree | 774fc0de56002abb3bb2b1c3387ff08f91876d17 /mrblib/array.rb | |
| parent | 9af3b7c6258de327218dd04e69d76ae68caf17b1 (diff) | |
| parent | d605b72c1d6fa4564a0a5e88535504b6850463b5 (diff) | |
| download | mruby-5eef75b678b41249cf4738ef42889090caea2ab0.tar.gz mruby-5eef75b678b41249cf4738ef42889090caea2ab0.zip | |
Merge pull request #4034 from i110/i110/inspect-recursion
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 d598efc77..2b080564c 100644 --- a/mrblib/array.rb +++ b/mrblib/array.rb @@ -83,13 +83,15 @@ class Array self end - def _inspect + def _inspect(recur_list) size = self.size return "[]" if size == 0 + return "[...]" if recur_list[self.object_id] + recur_list[self.object_id] = true ary=[] i=0 while i<size - ary<<self[i].inspect + ary<<self[i]._inspect(recur_list) i+=1 end "["+ary.join(", ")+"]" @@ -99,11 +101,7 @@ class Array # # 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 |
