1

I am new in solidity and trying some small code however I am getting error which I could not find.

I am trying below code

pragma solidity >=0.4.0 <0.6.0;

contract property {

    uint public value;
    string public location;
    //address public owner
    constructor(uint  _value, string _location) public {
          value = _value;
          location = _location;          
    }

    function setval(uint _value) public{
        value = _value;

    }

function getloc1() public pure returns(memory string) {,<--- getting error here
    return location;
  }
}

Error---

ParserError: Expected type name
function getloc1() public pure returns(memory string) {
                                       ^----^
1

I think you meant string memory, not memory string.

  • Thanks@smarx to edit my question, I will take care next time. Also the error has been remove from line 18 however new error come which is in line 8 constructor(uint _value, string _location) public as TypeError: Data location must be "memory" for parameter in function, but none was given. constructor(uint _value, string _location) public { ^--------------^ – Abhijeet Samanta Dec 17 '18 at 8:00
  • string memory _location – user19510 Dec 17 '18 at 8:03
  • Thanks@smarx for help, I know its was not up to level query however I am trying best and one day I will also contribute community. – Abhijeet Samanta Dec 17 '18 at 8:06

Your Answer

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

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