映射

可以认为是哈希,格式 mapping(_KeyType => _ValueType)

pragma solidity ^0.4.0;

contract MappingExample {
mapping(address => uint) public balances; function update(uint newBalance) public {
balances[msg.sender] = newBalance;
}
} contract MappingUser {
function f() public returns (uint) {
MappingExample m = new MappingExample(); // 存储在memory
m.update(100);
return m.balances(this);
}
}
05-18 11:19