Function overloading

As for other languages, Solidity has the ability to define different semantics for a function using different types and numbers of arguments. The following example shows the overloading of the editPlayer function:

function editPlayer(address _address,uint256 _id) public returns (bool) {
players[_address].id = _id;
return true;
}

This is essentially the same as the EditPlayer function we defined before, the difference being it will edit only the player's ID attribute. This overloaded function will be executed if EditPlayer is called with two arguments (string and uint256).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset