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.
对不起,我的蹩脚问题,但我坚持这个。
我需要使用默认构造函数创建结构哈希。我试过以下代码:
@@str = Struct.new("A", :x, :y) @data = Hash.new { |v,k| v[k] = @@str.new('1','2') }
但它不工作。如何做到这一点?
Struct.new("A", :x, :y) @data = Hash.new { |hash,key| hash[key] = Struct::A.new('1','2') }