How to use DART operators

In this article, i am going to explain about DART operators.
  • 2716

Equality and relational operator

DART supports different type of equality and relational operators.

Operators Meaning
= = To perform equality.
!= To perform, whether value is equal or not in compression to other variable.
= = = To perform, variable has a same instance
!== To perform, variable has not same instance.
> To perform, one value is greater than other or not.
< To perform, one value is less than other or not.
>= To perform, one value is greater or equal to other or not.
<= To perform, one value is lees  or equal to other or not.
is Returned true, if object has a specified type.
is! Returned false, if object has a specified type.

Example of equality and relational operator

void main() {

  int a=3;

  int b=2;

  int c=a;

  print("Welcome in DART relational and equality operators");

  if(a==3){

    print("Value of a is 3");

    if(a!=b){

      print("a is not equal to b");

      if(a===c){

        print("a and c are same instance");

        if(a!==b){

          print("a and b are't same instance");

          if(a>b){

            print("a is greater then b");

            if(b<a){

              print("b is less than a");

              if(a>=b){

                print("a is greater or or equal to b");

                if(b<=a){

                  print("b is less or equal to a");

                  if(a is int){

                    print("a is integer type variable");

                    if(a is! String){

                      print("a is define as a int not a String");

                    }

                  }

                }

              }

            }

          }

        }

      }

    }

  }

  else{

    print("False");

  }
}


Output:

relationalopers dart.jpg
 

Ask Your Question 
 
Got a programming related question? You may want to post your question here
 
© 2020 DotNetHeaven. All rights reserved.