[Contract] Solidity 判断 mapping 值的存在

通过llama.cpp与羊驼聊天的网页界面- 详解 Serge 的启动使用

 

比如 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."

 

Refer:Solidity巧用mapping

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

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

posted on 2020-02-25 17:09  ercom  阅读(1728)  评论(0编辑  收藏  举报