Skip to content

Instantly share code, notes, and snippets.

@amadeobrands
Created March 27, 2017 13:28
Show Gist options
  • Save amadeobrands/f1880ec4f866533fb66af08eda46531c to your computer and use it in GitHub Desktop.
Save amadeobrands/f1880ec4f866533fb66af08eda46531c to your computer and use it in GitHub Desktop.
Smart contract conditionals | Solidity
pragma solidity ^0.4.0;
contract SomeContract {
uint someVar;
function getMyVar() constant returns (string, uint) {
if(someVar > 2) {
return ("greater two", someVar);
} else if (someVar == 2) {
return ("is exactly two", someVar);
} else {
return ("is smaller two", someVar);
}
}
function setMyVar (uint myVar) {
someVar = myVar;
}
function getWhile() constant returns (uint) {
uint i = 0;
while(i < 5) {
i++;
}
return i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment