Created
August 12, 2018 13:38
-
-
Save daiki44/eaec3d48da1838fcd36ea5259f303f84 to your computer and use it in GitHub Desktop.
【Solidity】TypeError: Member “push” is not available in address[] memory outside of storage. ref: https://daiki-sekiguchi.com/2018/08/12/ethereum-solidity-member-push-is-not-available-in-address-memory-outside-of-storage/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.24; | |
contract ExampleContract { | |
function example(address _address) public view returns (address[]) { | |
address[] addressList; | |
for (uint i = 0; i < 100; i++) { | |
// memory で定義された配列は可変長の配列として扱えないためエラーが発生する | |
addressList.push(_address); | |
} | |
return addressList; | |
} | |
} |
Hi @jackningdl, this works in old solidity compiler versions but not in newer ones, since you're declaring a "view" function that potentially modifies storage.
Is there a solution where "view" modifier can be used?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I always implement like this...