I am reading this page and trying to understand how these 2 pieces of code will behave:
With require()
function transfer(address _newOwner) public {
require(msg.sender == owner)
// Do the actual transfer
}
With return
in an if()
:
function transfer(address _newOwner) public {
if (msg.sender != owner) return;
// Do the actual transfer
}
I understand that require()
will revert all changes and refund me any unused gas, but what exactly does the second code will behave? The function will stop executing, but does it refund unused gas?
Thanks