Output parameters

The output parameters can be declared after the return keyword, as shown in the following code snippet:

function getColor() public view returns (uint){
return uint(color);
}

In solidity, pure functions are functions that are promised not to modify, or read the state.

pure|constant|view|payable

If the function modifier is defined as view, it indicates that the function will not change the storage state.

If the function modifier is defined as pure, it indicates that the function will not read the storage state.

If the function modifier is defined as constant, it indicates that the function won't modify the contract storage.

If the function modifier is defined as payable, modifier can receive funds.

    uint amount =0;
function buy() public payable{
amount += msg.value;
}

In the preceding example, the buy function has a payable modifier, which makes sure you can send ethers to the buy function. A function without any name, and annotated with a payable keyword, is called a payable fallback function.

pragma solidity ^0.4.24;
// this is a contract, which keeps all Ether to it with not way of
// retrieving it.
contract MyContract {
function() public payable { }
}