DART ENUM

used for making user defined datatypes

e.g. enum Car {

            suv,

            hatchback,

            coupe,

            luxury

}                   

Now Car become a user datatypes and this contain these above names

call   Car.suv  ,  Car.coupe  etc.

In any func. we may write like       Car cartype   here cartype is variable under Car datatypes


DART TERNARY OPERATOR

Replacement for if else statement

if( cond. ) {

    .cond true then if runs.................

} else { 

       cond. rong then else

}

TERNARY OPERATOR SYNTAX

                                                condition ? if statement : else statement

void main(){

  bool lightSource = true; 

  lightSource == true? print('It is light source'): print('not light source');

}

different way of use of ternary operator

void main(){

  int myAge = 24;

  bool canBuyAlcohol = myAge > 21 ? true : false ;

   print(canBuyAlcohol);

}







Comments