Quiz Entry - updated: 2026.07.30
How do arrays work in Solidity — dynamic vs fixed size, and how do you add to one?
An array stores an ordered list; a dynamic array (type[]) can grow and shrink, a fixed array (type[3]) has a size locked at declaration. You append to a dynamic array with .push().
Person[] public people; // dynamic — any size
uint256[3] public topThree; // fixed — exactly 3 elements
people.push(Person(7, "Patrick")); // append
A dynamic array gives no size in the brackets and can grow indefinitely as you .push() items or shrink as you remove them. A fixed array like uint256[3] can never hold more than 3. Elements are accessed by zero-based index: people[0] is the first. A public array gets an auto-getter that takes an index and returns that element (returning the zero value if the index is empty). To reset a dynamic array you can reassign it a fresh empty one: people = new Person[](0);.
Go deeper:
Solidity docs: arrays — fixed vs dynamic,
push/pop, and array members.