Mapping是一种键值对的映射关系存储结构。语法是:mapping(_KeyType => _KeyValue)
Mapping通常与address结合使用
实例:
pragma solidity ^0.4.13;
// "0xca35b7d915458ef540ade6068dfe2f44e8fa733c",900
// "0x14723a09acff6d2a60dcdf7aa4aff308fddc160c",90
contract MappingExample{
mapping (address=>uint) balance;
function update(address a, uint newBalance) public{
balance[a]=newBalance;
}
function queryBalance(address a) constant public returns (uint){
return balance[a];
}
}