Below is my smart contract code for calculator.
pragma solidity 0.4.24;
contract Calculator{
uint result=10;
function Calculator() public
{
}
function getResult() public view returns (uint)
{
return result;
}
function addition(uint num) public
{
result=result+num;
}
function sub(uint num) public
{
result = result - num;
}
function mult(uint num) public
{
result =result*num;
}
function div(uint num) public
{
result = result/num;
}
}
Here what is the significance of view
keyword in below function?
function getResult() public view returns (uint)
My observation is:
- If I do not specify
view
keyword, remix browser is not showing me results. - If I specify the
view
keyword, I can see the result on UI.
But still I want to understand the significance of view
in solidity.