How to use assignment operators in DART

In this article, we will go to explain DART assignment operators.
  • 1832

Assignment operators

You can assign values using (=) equal operator and also use compound assignment operators, some of assignment operators is given below:

Operators Meaning
= For assign  values.
+= Assign with addition.
-= Assignment with subtraction.
*= Assignment with multiplication.
/= Assignment with division.
~/= It gives RoundOf  value and can operate on integer.
%= Assignment with reminder.
<<= Assignment with right shift.
>>= Assignment with right shift.


Example of assignment operators

void main() {

  var  a=3,b=2;

  int c=6,d=5,e=3;

  print("Welcome in DART assignment operator !");

  print("Value of b assign to a =${a=b}");

  print("Here two operation perform, (Addition and assignment) value is ${a+=b}"); // Here a value is 2 by above operation.

  print("Here two operation perform, (Subtraction and assignment) value is ${a-=b}"); // Here a value is 4 by above operation.

  print("Here two operation perform, (Multiplication and assignment) value is ${a*=b}"); //here a value is 2 by above operation.

  print("Here two operation perform, (Division and assignment) value is ${a~/=b}"); // here a value is 4 by above operation.

  print("Here two operation perform, (Division and assignment) value is ${a/=b}"); // here a value is 2 by above operation.

  print("Here two operation perform, (Reminder plus assignment) value is ${a%=b}"); // here a value is 2 by above operation.

  print(" value of (c~/d) is ${c~/=d} or if not use negation value of (a/=b) is ${a/=b}");

  print("Here two operation perform, (Leftshift plus assignment) value is ${e<<=b}"); // here a value is 2 by above operation.

  print("Here two operation perform, (Rightshift plus assignment) value is ${e<<=b}"); // here e value is 12 by above operation.

}

Output:


assignment.jpg


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