1

I am aware that we need to specify data location for returned values in function as of Solidity v0.5. Is this the case for all variable types (I have come across sources that mention it is only for struct, arrays, and mapping)?

I am trying to run the following code but for some reason it only requires the string variable to have a data location specified, and not the uint or bool values:

// Get user information using an address
function getUser(address _address) public view returns(string memory, uint, bool) {
    User memory getM = addressToUser[_address];
    return(getM.username,getM.contributionBalance,getM.verified);
}

This code gives no compilation errors but adding memory to uint and bool does. I wondered why this is the case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.