don't print anonymous struct class name

parent 20a4e9ad
......@@ -47,7 +47,12 @@ if Object.const_defined?(:Struct)
end
def _inspect
str = "#<struct #{self.class.to_s} "
name = self.class.to_s
if name[0] == "#"
str = "#<struct "
else
str = "#<struct #{name} "
end
buf = []
self.each_pair do |k,v|
buf.push [k.to_s + "=" + v._inspect]
......
......@@ -103,7 +103,7 @@ end
assert('struct inspect') do
c = Struct.new(:m1, :m2, :m3, :m4, :m5)
cc = c.new(1,2,3,4,5)
assert_equal "#<struct #{c.inspect} m1=1, m2=2, m3=3, m4=4, m5=5>", cc.inspect
assert_equal "#<struct m1=1, m2=2, m3=3, m4=4, m5=5>", cc.inspect
end
assert('Struct#length, Struct#size') do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment