Solidity Programming Language – Dynamic Sized Array
In Solidity, if you want an array whose size can change dynamically during execution, you should use a data structure called a “dynamic array” or “dynamic-sized array.” In Solidity, this is commonly achieved using the push
method on a storage array.
Remember that dynamic arrays in Solidity can be more gas-expensive compared to fixed-size arrays, so you should consider the gas cost when using dynamic arrays, especially in scenarios where gas efficiency is crucial.
Code: