Created
February 18, 2010 22:58
-
-
Save kronos/308179 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/kernel/common/array.rb b/kernel/common/array.rb | |
index 06b3fe8..d8c860f 100644 | |
--- a/kernel/common/array.rb | |
+++ b/kernel/common/array.rb | |
@@ -819,13 +819,14 @@ class Array | |
# is constructed by calling #inspect on all elements. | |
# Descends through contained Arrays, recursive ones | |
# are indicated as [...]. | |
- def inspect() | |
- out = [] | |
+ def inspect | |
+ comma = ', ' | |
+ result = '[' | |
return "[...]" if Thread.detect_recursion self do | |
- each { |o| out << o.inspect } | |
+ each { |o| result << o.inspect << comma } | |
end | |
- | |
- "[#{out.join ', '}]" | |
+ result.shorten!(2) | |
+ result << ']' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment