I am new to solidity and I have been trying to print out simple messages using functions in solidity, but I have failed to deploy successfully, and there is an error that I can not figure out what's wrong.
This is what I have tried so far:
pragma solidity ^0.6.0;
contract test {
string public _feedback;
function reply(string memory feedback) public
{
feedback = "Well done!";
}
}
The error I am receiving is "Warning: Function state mutability can be restricted to pure function"
_feedback
, which you neither read nor write to, and one in memory calledfeedback
, to which you immediately assign the hard-coded value "Well done!" in the function. The string provided as an argument is never used. In addition, if you want the function to return something (say,feedback
) you need to specifyfunction reply(string memory feedback) public returns(string feedback);
Could you give us an idea of how you'd like this contract to behave? – Brahmanism