pragma solidity ^ 0.5.0;
contract memeRegistry {
pragma solidity ^0.5.0;
contract memeRegistry {
string url;
string name;
uint timestamp;
function setmeme(string _url,string _name, uint _timestamp) public{
url = _url;
name = _name;
timestamp = _timestamp;
}
}
Run Code Online (Sandbox Code Playgroud)
}
现在必须显示struct,array或mapping类型的所有变量的显式数据位置.这也适用于函数参数和返回变量.
memory之后添加string
function setmeme(string memory _url, string memory _name, uint _timestamp) public{
Run Code Online (Sandbox Code Playgroud)
点击此处查看Solidity 0.5.0.更改https://solidity.readthedocs.io/en/v0.5.0/050-breaking-changes.html
//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;
}
}
Run Code Online (Sandbox Code Playgroud)