# Returning dynamic arrays from functions

When returned by a function, dynamic arrays are pushed on the stack by reference.

Therefore, you can create a dynamic array in a function and return it to the caller for usage:

```
MAIN
DEFINE arr DYNAMIC ARRAY OF INTEGER
LET arr = create_array(10)
DISPLAY arr.getLength()
END MAIN
FUNCTION create_array(n)
DEFINE n, i INTEGER
DEFINE arr DYNAMIC ARRAY OF INTEGER
FOR i=1 TO n
LET arr[i] = i
END FOR
RETURN arr
END FUNCTION
```