Hey all help required. I have a guess tho that on this contract bellow, i would need to assign the updated balance to the momory? The reason i presume the new updated balance is not showing is because its not getting stored in memory?
i have tried to add it in to the contract bellow but im getting Sytax error on the line…
pragma solidity 0.5.1;
contract MemoryAndStorage {
mapping(uint => User) users;
struct User{
uint id;
uint balance;
}
function addUser(uint id, uint balance) public {
users[id] = User(id, balance);
}
function updateBalance(uint id, uint balance) public {
User memory user = users[id];
// MY EDIT IS BELLOW
user memory .balance = balance;
}
function getBalance(uint id) view public returns (uint) {
return users[id].balance;
}
}
Thanks all.
Rob.