Solidity Output Prediction Medium +20 XP
Mapping Default
What does a mapping return for a key that was never set?
SolidityRead-only
mapping(address => uint) public balances; // balances[unknownAddr] = ?
What is the output?
Show answer and explanation
Answer: 0 (default value)
In Solidity, mappings return the default value of the value type for unknown keys. For uint, the default is 0.
Hint: Every type in Solidity has a zero value.
What this challenge tests
Output Prediction in Solidity: mappings, defaults.