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;


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

2 Answers 2


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 { ^--------------^ Dec 17, 2018 at 8:00
  • string memory _location
    – user19510
    Dec 17, 2018 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. Dec 17, 2018 at 8:06
  1. use string memory and remove the comma(,) from the {}.
  • 2
    If you answer a very old question, you should provide more details that existing answers.
    – Ismael
    Dec 5, 2022 at 14:26
  • yeah sure , i'll Dec 15, 2022 at 9:37

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.