I am trying to return a list of addresses by declaring an array and pushing to it in a for loop. However, Solidity doesn't like when I try to return a dynamic array.
function listMyPromises() public returns(uint256[] memory ){ //lists all my past promises
uint256[] memory List;
for(uint i=0; i<table.length; i++){
if(table[i].userAddress==msg.sender){
List.push(uint256(table[i].friendAddress));
}
}
return List;
}
Solidity is not allowing me to return a array stating that
TypeError: Data location must be "memory" or "calldata" for return parameter in function, but none was given. However When I add memory in the return parameter I get the error: TypeError: Member "push" is not available in uint256[] memory outside of storage
I have no clue what to do.