Tricky thing is that if we do delete scores[msg.sender][0] array element with index 0 is not being deleted and array shifted left (as might be expected) - it's just getting value of 0 mapping(address => uint[]) public scores; function deleteScore() external { scores[msg.sender].push(10); scores[msg.sender].push(15); scores[msg.sender].push(20); delete scores[msg.sender][0]; } Result : uint256[] : score 0,15,20
OMG you saved me! Literally saved me. I was implementing a Dapp and couldn't understand the mapping in solidity.... More and more stack overflow question, sites, forum.... And then you. Thank you so much bro! 🙏🏻🙏🏻🙏🏻🙏🏻
@@liotr6737 this was a university project Lionel, we had to learn solidity and developed a Dapp in just two months... With other 3 different courses in parallel 😉
Hello, thank you for your videos :) In your example //4 exotic mapping I assume the variable that should have been used/indicated should be "approved" and not "balances" right?
Thank you Julian, your video helped me a lot to get started. Looking forward to do your courses. But I have a question about, What is the default value for structs in mappings? (If a struct is not assigned in a mapping) - Is it possible to do so or have to access each value of struct separately?
Hi julian. Great work! This video tutorial has helped me a lot to build my first ethereum Dapp. A newbie question: lets say I'm storing data inside a mapping (string=>uint). When i make function call from my web app to the mapping storage variable function, it returns 0 if there's no match and stored uint value if thrs a match as expected. Incase the value is non zero (i.e, there a matched value inside the mapping) how do i get the transaction hash of the corresponding matched input along with the return value?
Is the nested mapping similar to a "join" operation in sql? If so am I right to assume that it is similar to a "full join" in sql since all the nested mapping data have corresponding connection with the original mapping data?
That's a limitation of the EVM (Ethereum virtual machine). We just have to work with this limitation. You can pack several piece of data into one by using arrays, mapping bytes on the field of your struct
Tricky thing is that if we do delete scores[msg.sender][0] array element with index 0 is not being deleted and array shifted left (as might be expected) - it's just getting value of 0
mapping(address => uint[]) public scores;
function deleteScore() external {
scores[msg.sender].push(10);
scores[msg.sender].push(15);
scores[msg.sender].push(20);
delete scores[msg.sender][0];
}
Result : uint256[] : score 0,15,20
OMG you saved me! Literally saved me. I was implementing a Dapp and couldn't understand the mapping in solidity.... More and more stack overflow question, sites, forum.... And then you. Thank you so much bro! 🙏🏻🙏🏻🙏🏻🙏🏻
Great to hear!
It's very reassuring that our dapp developers who launch smart-contract don't even understand basic type of their langage lol
@@liotr6737 this was a university project Lionel, we had to learn solidity and developed a Dapp in just two months... With other 3 different courses in parallel 😉
I like your work, keep it up and please point me to a complete project end to end if you have any
thanks, you can checkout this full tutorial here:
ua-cam.com/video/8wMKq7HvbKw/v-deo.html
Thank you very much for the tutorial, I did need to learn about from Mapping and this video I help me. Regards from Argentina.
welll explained ! good job and thanks
Hello, thank you for your videos :)
In your example //4 exotic mapping I assume the variable that should have been used/indicated should be "approved" and not "balances" right?
yes you're right
i noticed too, you are right, it should be approved not balance;
Oh, he later made the corrections, I guess I just rushed here to point out the mistake 🤦🏽♀️🤦🏽♀️🤦🏽♀️
Tic tac tic tac...
You re fired ,you didn't get the right answer
This got me
nicely explained
Thank you Julian, your video helped me a lot to get started. Looking forward to do your courses.
But I have a question about, What is the default value for structs in mappings? (If a struct is not assigned in a mapping) - Is it possible to do so or have to access each value of struct separately?
You can also have access to a struct using arrays..not only mappings
"How to initialize a struct?" Maybe this is the question you ask?
By the way I downloaded your free course Smart contract security which is actually paid in your website
Hi julian. Great work! This video tutorial has helped me a lot to build my first ethereum Dapp.
A newbie question: lets say I'm storing data inside a mapping (string=>uint). When i make function call from my web app to the mapping storage variable function, it returns 0 if there's no match and stored uint value if thrs a match as expected. Incase the value is non zero (i.e, there a matched value inside the mapping) how do i get the transaction hash of the corresponding matched input along with the return value?
I am not sure to understand the question, but you get the tx hash of a transaction with web3 or ethers, outside of the blockchain
very helpfull
Thank you
Thanku lots
another instructive video.
Glad you liked it!
Are you saving that automatically all variables get initialized to default values?
For Boolean, is setting it to false , the same as deleting?
How to get the length of array nested inside mapping ? I want to iterate through the array so I need to know the length
you can access the length property, like for arrays that are not nested in mappings
What is the meaning of "msg.sender"
the address that sent the transaction
Is the nested mapping similar to a "join" operation in sql? If so am I right to assume that it is similar to a "full join" in sql since all the nested mapping data have corresponding connection with the original mapping data?
I second you.
I love your tutorials but why is it that a struct can only take 7 to 8 variables anthing more than that will result to stack too deep error
That's a limitation of the EVM (Ethereum virtual machine). We just have to work with this limitation. You can pack several piece of data into one by using arrays, mapping bytes on the field of your struct
5:34 😅