How to use enum in Solidity programming langauge ?

How to use enum in Solidity programming langauge ?


pragma solidity ^0.5.0;


contract test {

   enum FreshJuiceSize{ SMALL, MEDIUM, LARGE }

   FreshJuiceSize choice;

   FreshJuiceSize constant defaultChoice = FreshJuiceSize.MEDIUM;


   function setLarge() public {

      choice = FreshJuiceSize.LARGE;

   }

   function getChoice() public view returns (FreshJuiceSize) {

      return choice;

   }

   function getDefaultChoice() public pure returns (uint) {

      return uint(defaultChoice);

   }

}

Comments

Last 7 Days

How to use referrerpolicy Attribute value ( origin-when-cross-origin ) with < iframe > tag in HTML ? with example

All 35 reserved keywords in Solidity programming language

How to use the datalist tag in HTML?

How to use Local Variable for whose values are present till function is executing in solidity ?

How to use sandbox attribute value ( allow-top-navigation-by-user-activation) with < iframe > tag in HTML ? with example

Css source code for scrollbars

What does < Article > mean in HTML?

table background-color css