2018-11-19 10:29:02 +00:00
|
|
|
pragma solidity ^0.5.0;
|
2018-08-21 19:25:18 +00:00
|
|
|
|
|
|
|
contract Branches {
|
|
|
|
uint public lastComparison;
|
|
|
|
uint public storedData;
|
|
|
|
|
|
|
|
constructor(uint initialValue) public {
|
|
|
|
storedData = initialValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
function bigger(uint x) public returns (uint biggest) {
|
|
|
|
lastComparison = x;
|
|
|
|
|
|
|
|
if(x > storedData) {
|
|
|
|
storedData = x;
|
|
|
|
return x;
|
|
|
|
} else {
|
|
|
|
return storedData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function smaller(uint x) public returns (uint smallest) {
|
|
|
|
lastComparison = x;
|
|
|
|
|
|
|
|
if(x < storedData) {
|
|
|
|
return x;
|
|
|
|
} else {
|
|
|
|
return storedData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get() public view returns (uint retVal) {
|
|
|
|
return storedData;
|
|
|
|
}
|
2018-09-26 15:13:14 +00:00
|
|
|
|
|
|
|
function smallFunctionWithoutStatements() public view returns (uint retVal) {
|
|
|
|
if(false) return storedData * 10;
|
|
|
|
if(true) return storedData * 20;
|
|
|
|
}
|
2018-08-21 19:25:18 +00:00
|
|
|
}
|