Skip to content

Commit 1a3245b

Browse files
authored
Replacing if statement with ternary operator (#198)
* replacing if with ternary operator * Update contracts/UFragments.sol
1 parent 97c89a1 commit 1a3245b

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

contracts/UFragments.sol

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,7 @@ contract UFragments is ERC20Detailed, Ownable {
358358
*/
359359
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
360360
uint256 oldValue = _allowedFragments[msg.sender][spender];
361-
uint256 newValue;
362-
if (subtractedValue >= oldValue) {
363-
newValue = 0;
364-
} else {
365-
newValue = oldValue.sub(subtractedValue);
366-
}
361+
uint256 newValue = (subtractedValue >= oldValue) ? 0 : oldValue.sub(subtractedValue);
367362

368363
_allowedFragments[msg.sender][spender] = newValue;
369364
emit Approval(msg.sender, spender, newValue);

0 commit comments

Comments
 (0)