The title is a little bit vague but I've seen this contract and tried it on remix:
pragma solidity ^0.4.24;
contract Tester {
struct Account {
uint256 balance;
}
mapping (address => Account) public accounts;
function addBalance() public payable {
Account storage a = accounts[msg.sender];
a.balance = a.balance + msg.value;
}
}
What happens is the following:
1. I check the value in the mapping and it's 0
2. I execute the addBalance
function sending 10 wei
3. I check the value in the mapping and I see it's 10
How is that possible ? I am not updating the mapping.