Как вернуть строку в версии компилятора Solidity 0.5.0?
contract Test {
string public text = 'show me';
function test() public view returns (string) {
return text;
}
}
Я получил сообщение об ошибке:
TypeError: Data location must be "memory" for return parameter in function, but none was given.





Просто нужно добавить memory после string, например:
function test() public view returns (string memory) {
Еще изменения: https://solidity.readthedocs.io/en/v0.5.0/050-breaking-changes.html#interoperability
//The version I have used is 0.5.2
pragma solidity ^0.5.2;
contract Inbox{
string public message;
//**Constructor** must be defined using “constructor” keyword
//**In version 0.5.0 or above** it is **mandatory to use “memory” keyword** so as to
//**explicitly mention the data location**
//you are free to remove the keyword and try for yourself
constructor (string memory initialMessage) public{
message=initialMessage;
}
function setMessage(string memory newMessage)public{
message=newMessage;
}
function getMessage()public view returns(string memory){
return message;
}}