Arrays
內部結構數組和數組
可以將結構保存在數組中,並將所有這些數組保存在同一個數組中。我是說:
[ [{"struct"}, {"struct"}, {"struct"}], [ {"struct"}, {"struct"}], [{"struct"}, {"struct"}, {"struct"}, {"struct"}] ]
我在網上找不到與此相關的內容。
並且有效地實施了這個儲存系統。如果數組太大會增加交易成本。是否有利可圖?
是的,你可以有一個結構數組的數組。
pragma solidity >= 0.4.25 < 0.6; contract Bank { struct Customer { uint age; } Customer[][] customers; function foo() public { if (customers.length > 0) { Customer[] storage northBranch = customers[0]; if (northBranch.length > 1) { Customer storage customer = northBranch[1]; customer.age = 23; } } else { Customer memory bob; bob.age = 34; customers.length += 1; customers[0].push(bob); } } }
對於其他答案,我會說這取決於特定用途。