Memory array can't use for argument value, can it?

kenmazsymakenmazsyma tokyoMember Posts: 13
I compiled following code.

```
function getArr() {
uint256[] arr;
arr[arr.length++] = 1;
arr[arr.length++] = 2;
arr = deleteItem(arr, 1);
}

function deleteItem(uint256[] ars, uint idx) returns(uint[] ret) {
return ars;
}
}
```


and I got following error.

```
solidity/test.sol:27:3: Warning: Uninitialized storage pointer. Did you mean ' memory arr'?

uint256[] arr;
^-----------^

solidity/test.sol:33:9: Error: Type uint256[] memory is not implicitly convertible to expected type uint256[] storage pointer.

arr = deleteItem(arr, 1);
^----------------^
```

I change code as following, whereupon errors didn't occur.

```
uint256[] arr;
function getArr() {
//uint256[] arr;
arr[arr.length++] = 1;
arr[arr.length++] = 2;
arr = deleteItem(arr, 1);
}

function deleteItem(uint256[] ars, uint idx) returns(uint[] ret) {
return ars;
}
}
```

Memory array can't use for function argument value, can it?

Comments

Sign In or Register to comment.