Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试引用二维哈希。有谁知道为什么下面不会输出true以及如何更改它以使其输出?
true
grid = Hash.new(false) grid [[3,2]] = true current_position = [3,2] puts grid[[current_position]]
哈希中的键[3,2]等效于current_position,因此要访问内容,它是:
[3,2]
current_position
puts grid[current_position]