December 2018
Beginner to intermediate
564 pages
17h 34m
English
Mapping is used for key-to-value mapping. Mappings can be seen as hash tables that are virtually initialized such that every possible key exists and is mapped to a default value. The default value is all zeros. The key is never stored in a mapping, only the keccak256 hash is used for value lookup. Mapping is defined just like any other variable type. Take a look at this code:
contract Gotham { struct Batman { string friends; string foes; int funds; string fox; } mapping (address => Batman) Catwoman; address[] public Batman_address;}
The preceding code example shows that Catwoman is being initialized as a mapping.
Read now
Unlock full access