Below is the code which I saw on Solidity official site
pragma solidity >=0.4.0 <0.9.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();
m.update(100); // **LINE 1**
return m.balances(address(this)); **LINE 2**
}
}
What is m.update(100)
is doing in contract ? I thought that it will be passing value 100 in the paramter newBalance
in function update
of contract MappingExample
. But it is taking value from user.
Secondly , please explain to me what role does line 2 i.e m.balances(address(this))
have in here.