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 sandbox attribute value ( allow-top-navigation) with < iframe > tag in HTML ? with example

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

How to use loop attribute with < video > tag in HTML for YouTube ? with example

How to use string in Solidity programming language ?

Tag is used to create inline frame ?