Skip to main content
edited tags
Link
eth
  • 86.5k
  • 53
  • 287
  • 411
edited tags
Link
Source Link

Return a String with function giving an error in Solidity 0.5.1

Pretty new to solidity and I was watching some tutorial on web. and my function is giving an error while trying to return a string from a function.

Below is my simple contract:

pragma solidity ^0.5.1;

contract and {
    
    string d = "Hello";
    
    function getValueOfabc() public view returns(string) {
        return d;
    }
}

And function getValueOfabc() public view returns(string) { is giving me below error:

browser/mulreturn.sol:7:50: TypeError: Data location must be "memory" for return parameter in function, but none was given.
    function getValueOfabc() public view returns(string) {
                                                 ^----^ 

The above code is working fine with version 0.4.25