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 ( no-referrer-when-downgrade ) with < iframe > tag in HTML ? with example

Difference between Public vs Internal vs Private state variables in solidity programming langauge with example ?

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

How to make a water bottle using the HTML code?

How to use autoplay and mute attribute with < video > tag in HTML for youtube ? with example

Syntax of code tag in HTML

What is img scr or image scr or scr img ?