Skip to main content
added 201 characters in body
Source Link

No.

A function returns a result once. It cannot loop over all your array, and returns a tuple at each iteration.

You can return a dynamic sized array to an external function call ( contract exterior : e.g web3 / other contract ).

In theory it can work like this :

function getList() external returns (string[], address[]) {

        return (arrayOfStringValues[], arrayOfAddressValues[]);
}

But you would have an error as you can't return string[] yet in solidity. so if you can find a way to use bytes32 instead of string, it should work.

Note : If you need to call this external function from inside your contract you can use this.getList() as it will make it look as an external call.

EDIT : i just saw that the latest solidity release 0.4.22 opens the possibility to return string[] and bytes32[] in functions without the external modifier. ( someone verify this please )

You can return a dynamic sized array to an external function call ( contract exterior : e.g web3 / other contract ).

In theory it can work like this :

function getList() external returns (string[], address[]) {

        return (arrayOfStringValues[], arrayOfAddressValues[]);
}

But you would have an error as you can't return string[] yet in solidity. so if you can find a way to use bytes32 instead of string, it should work.

Note : If you need to call this external function from inside your contract you can use this.getList() as it will make it look as an external call.

No.

A function returns a result once. It cannot loop over all your array, and returns a tuple at each iteration.

You can return a dynamic sized array to an external function call ( contract exterior : e.g web3 / other contract ).

In theory it can work like this :

function getList() external returns (string[], address[]) {

        return (arrayOfStringValues[], arrayOfAddressValues[]);
}

But you would have an error as you can't return string[] yet in solidity. so if you can find a way to use bytes32 instead of string, it should work.

Note : If you need to call this external function from inside your contract you can use this.getList() as it will make it look as an external call.

EDIT : i just saw that the latest solidity release 0.4.22 opens the possibility to return string[] and bytes32[] in functions without the external modifier. ( someone verify this please )

Source Link

You can return a dynamic sized array to an external function call ( contract exterior : e.g web3 / other contract ).

In theory it can work like this :

function getList() external returns (string[], address[]) {

        return (arrayOfStringValues[], arrayOfAddressValues[]);
}

But you would have an error as you can't return string[] yet in solidity. so if you can find a way to use bytes32 instead of string, it should work.

Note : If you need to call this external function from inside your contract you can use this.getList() as it will make it look as an external call.