HI Carlos, Hope you are well.
Your replies are helping me to learn about the logics which computer can understand,
-
from your reply, i understood that mapping does not return struct with string and uint , it only returns integers like, addresses, balances. I understand now that mapping is to get value from address primarily and it does not take in strings value because it is mapping, not array.
-
mapping ( address => User) users;
// means it is a mapping named users which each key address will return the value based on struct. Correct ?
function addUser ( uint address, uint balance) public {
users[address] = User ( address , balance);
} // Correct ?
// This means that if we enter 1,100 into addBalance function in remix, it will throw an error because it requires a address type, it will not accept uint. Correct ?
While users{id] = User storage user ;
// does not make sense in the updateBalance function, because a storage variable needs to be created first before it is āpushedā into ( users[id]), but rather
User storage user = users[id];
// a storage variable named user is created based on struct User, and is āpushedā into user[id], Correct ?
- As for :
function addUser (uint address, uint balance) public {
users[id] = User ( address, balance );
}
is users[id] = User (id, balance);
also the same as User ( id, balance) =users[id] ?
Just like, b=2 being the same as 2=b ?
Sorry if i am confusing you. Thank you for your patience.