I'm trying to declare an in-memory array with a fixed length:
uint length = 10;
uint[length] memory priorityList;
However, it just displays this error message:
Invalid array length, expected integer literal
Do I have to do uint[10] memory priorityList;
or is there a way I can still use a variable to declare the size?
Best Answer
As per documentation:
Creating arrays with variable length in memory can be done using the
new
keyword.You can use following code snippet to solve your problem.