Skip to content
Permalink
Browse files

Merge pull request #542 from jstepien/hash-to-s

Hash#{to_s,inspect} based on Array#inspect
  • Loading branch information
alex committed Mar 22, 2013
2 parents e59876b + df49154 commit 5cf9493a6bc7c3015dcb6129896425793a46ad61
Showing with 18 additions and 6 deletions.
  1. +18 −0 lib-topaz/hash.rb
  2. +0 −3 spec/tags/core/hash/inspect_tags.txt
  3. +0 −3 spec/tags/core/hash/to_s_tags.txt
@@ -69,4 +69,22 @@ def rassoc(value)
end
nil
end

def inspect
result = "{"
recursion = Thread.current.recursion_guard(:hash_inspect, self) do
self.each_with_index do |key, i|
if i > 0
result << ", "
end
result << "#{key.inspect}=>#{self[key].inspect}"
end
end
if recursion
result << "..."
end
result << "}"
end

alias :to_s :inspect
end

This file was deleted.

This file was deleted.

0 comments on commit 5cf9493

Please sign in to comment.
You can’t perform that action at this time.