上QQ阅读APP看书,第一时间看更新
Enums
Enums are fixed size lists with unique names that you define. You can use them as custom modifiers for specific objects, or to hold a specific state in your smart contract. This is ideal for controlling the state of ICOs.
You declare them as follows:
enum Trees { RedTree, BlueTree, GreenTree, YellowTree }
Then, you create the enum variable:
Trees public myFavoriteTree = Trees.RedTree;
Note that you don't have to add a semicolon at the end of the enum declaration, but you do have to add it for the variable with the enum type that you just created.