lessonΒ·25 minΒ·Chapter 2 of 3
Mappings & Arrays
Mappings are hash tables: `mapping(address => uint256) public balances;`. They provide O(1) lookups but can't be iterated. Arrays can be fixed-size (`uint[5]`) or dynamic (`uint[]`). Dynamic arrays in storage can be pushed to and popped from. Important: mappings can only live in storage, not memory. A common pattern combines both: use a mapping for O(1) lookup and an array to track all keys for iteration.
π‘ Key Takeaway
This lesson covers the fundamental concepts. Make sure you understand these before moving to the next chapter.