60 - Memory Arrays
Memory arrays with dynamic length can be created using the new
operator
-
As opposed to storage arrays, it is not possible to resize memory arrays i.e. the
.push
member functions are not available -
You either have to calculate the required size in advance or create a new memory array and copy every element
- Memory Arrays
- Dynamic -> No Operator
- Memory & Storage
- Cannot Resize -> No push
- Calculate Size -> Advance
- New Array -> Copy Over
- E.g.:
uint[] memory a = new uint[](7);