【发布时间】:2012-12-25 01:06:36
【问题描述】:
我有这个代码:
$ze = Hash.new( Hash.new(2) )
$ze['test'] = {0=> 'a', 1=>'b', 3 => 'c'}
$ze[5][0] = 'one'
$ze[5][1] = "two"
puts $ze
puts $ze[5]
这是输出:
{"test"=>{0=>"a", 1=>"b", 3=>"c"}}
{0=>"one", 1=>"two"}
为什么没有输出:
{"test"=>{0=>"a", 1=>"b", 3=>"c"}, 5=>{0=>"one", 1=>"two"}}
{0=>"one", 1=>"two"}
?
【问题讨论】:
-
不要使用全局变量,它们很丑!