Code has been added to clipboard!
Solidity Value Types Enums
Example
enum moveChoice { moveLeft, moveRight, moveStraight, stayStill }
moveChoice currentChoice;
moveChoice constant defaultChoice = moveChoice.moveStraight;
function moveGoStraight() {
choice = moveChoice.moveStraight;
}
// Due to enum types not being a part of the ABI, the signature of "getChoice"
// will be changed to "getChoice() returns (uint8)" automatically
// for everything external to Solidity. The integer type that was used is simply
// large enough for holding all enum values, for example, if you have multiple values,
// `uint16` is going to be used and so on.
function getChoice() returns (moveChoice) {
return currentChoice;
}
function getDefaultChoice() returns (uint) {
return uint(defaultChoice);
}