Last active
February 9, 2018 00:32
-
-
Save mishfit/7b75f82dd18f9fed816d01481c0eb3ee to your computer and use it in GitHub Desktop.
Revert Costs Less Than Require
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.19; | |
contract CompareAssertions { | |
function requireExample (uint256 input) public pure returns (uint256) { | |
require(input > 5); | |
uint256 result = 5 * input; | |
require(result > input); | |
return result; | |
} | |
function revertExample (uint256 input) public pure returns (uint256) { | |
uint256 result; | |
if (input < 5 || ((result = 5 * input) < input)) revert(); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment