【发布时间】:2013-01-11 10:24:28
【问题描述】:
当我想调试以下哈希时,它返回try2test2。
dictionary = {
"test" => 2,
"try" => 2
}
puts dictionary
# => try2test2
有没有其他方法可以为您提供完整的列表,如{'test': 2, 'try': 2}?
【问题讨论】:
-
你试过
dictionary.inspect吗? -
您使用的是哪个 ruby 版本?
Hash#to_s不应像try2test2一样返回。 -
dictionary.inspect 有效!非常感谢!