mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-06 06:47:54 +02:00
corrections in mapping example (#2371)
fixed two small errors in the example mapping called balances
This commit is contained in:
@@ -230,9 +230,9 @@ mapping (string => uint) public balances;
|
|||||||
balances["charles"] = 1;
|
balances["charles"] = 1;
|
||||||
console.log(balances["ada"]); // is 0, all non-set key values return zeroes
|
console.log(balances["ada"]); // is 0, all non-set key values return zeroes
|
||||||
// 'public' allows following from another contract
|
// 'public' allows following from another contract
|
||||||
contractName.balances("claude"); // returns 1
|
contractName.balances("charles"); // returns 1
|
||||||
// 'public' created a getter (but not setter) like the following:
|
// 'public' created a getter (but not setter) like the following:
|
||||||
function balances(address _account) returns (uint balance) {
|
function balances(string _account) returns (uint balance) {
|
||||||
return balances[_account];
|
return balances[_account];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user