Mapping
mapping (address => uint) public peopleAges;Initialization & Assignment
Assignment of values must be done inside a function
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract SimpleMappingExample {
mapping(uint => bool) public myMapping;
mapping(address => bool) public myAddressMapping;
function setValue(uint _index) public {
myMapping[_index] = true;
}
function setMyAddressToTrue() public {
myAddressMapping[msg.sender] = true;
}
}Nested Mapping
Last updated

