Type Test Operators Example Program in Dart


This Dart code is demonstrating the use of the is and is! operators to test if a variable is of a certain type. Here's what's happening in this code:

  • var a = 25.0; : This line declares a variable a and initializes it with the value 25.0, which is a floating-point number.
  • print(a is int); : This line uses the is operator to test if a is of type int. Since a is not an integer, this will print false to the console.
  • print(a is! int); : This line uses the is! operator to test if a is not of type int. Since a is not an integer, this will print true to the console.

In summary, this code demonstrates how to use the is and is! operators in Dart to test if a variable is of a certain type or not.

Source Code

void main(){
  var a=25.0;
  print(a is int);
  print(a is! int);

}
To download raw file Click Here

Output

true
false