[Contract] Solidity 判斷 mapping 值的存在


 

比如 mapping(address => uint) tester,只需要判斷 mapping 是否為默認值 0, tester[msg.sender] == 0

 

"You can think of mappings as hash tables, which are virtually initialised such that every possible key exists and is mapped to a value whose byte-representation is all zeros, a type’s default value."

 

Docs:https://solidity.readthedocs.io/en/v0.6.3/types.html#mapping-types

Link:https://www.cnblogs.com/farwish/p/12362647.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM