0
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;
    
contract MyContract{
        address[] public myAddresses;
    
        function getMyAddresses() public view returns(address[] [[memory? / storage?]]){
            return myAddresses;
        }
    }

Thanks in advance.

1 Answer 1

0

Whenever you want to return an array or a string from a function, you need to specify "memory" in the returns statement. This is because the contract would need to store the returned data somewhere. Since storing in the "storage" needs gas, the location chosen is "memory".

For detailed description, you should refer to this article.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.