Skip to content

Instantly share code, notes, and snippets.

@kronos
Created February 18, 2010 22:58
Show Gist options
  • Save kronos/308179 to your computer and use it in GitHub Desktop.
Save kronos/308179 to your computer and use it in GitHub Desktop.
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