August 2019
Intermediate to advanced
486 pages
13h 52m
English
Like other languages such as C++ and Java, Solidity supports enumerations. Enums can be used to create a custom data type with a fixed set of constant values. Enums will have integer values assigned, starting from 0 and ascending to the number of states defined in enum. Enums in Solidity adopts to uintX data types starting from uint8 up to uint256. According to the number of values present in enum, compiler chooses the data type to be used. For example, when having 1 - 255 number of values defined in an enum would use uint8, however, it will use uint16 when a few more than 255 values are used.
As shown in the example code here, by default, the status variable will be set to 0:
contract LoanStruct { //Enum ...