dart operators

// first individual use

void main() {
  int x = 5;
  int y = 2;
  int z = x + y; // collection operator
  int z = x - y; // extraction operator
  int z = x * y; // impact operator
  int z = x / y; // divide operator
  
}

// seconds if else operators

void main() {
   int x = 2;
   int y = 5;
   if(x == y) {} // equality operator
   if(x < y) {} // less than sign operator
   if(x > y) {} // greater operator
   if(x <= y) {} // less than sign or equality operator
   if(x >= y) {} // greater or equality operator
}

// I guess that's enough for now, good coding <3

operators in dart

Dart supports the following types of operators.

1.Arithmetic Operators
2.Assignment Operators
3.Relational Operators
4.Type test Operators
5.Logical Operators
6.Bitwise Operator
7.Conditional Operators
8.Casecade notation(..) Operators


1.Dart Arithmetic Operators

Example -
void main(){  
  print("Example of Assignment operators");  
  var n1 = 10;  
  var n2 = 5;  
    
  print("n1+n2 = ${n1+n2}");  
  print("n1-n2 = ${n1-n2}");  
  print("n1*n2 = ${n1*n2}");  
  print("n1/=n2 = ${n1/n2}");   
  print("n1%n2 = ${n1%n2}");     
} 

Output:
Example of Arithmetic operators 
n1+n2 = 15 
n1-n2 = 5 
n1*n2 = 50 
n1/=n2 = 2 
n1%n2 = 0

2. Unary Operators (post and pre)

Example -
void main() {   
   var x = 30;   
   print(x++);                  //The postfix value  
     
var y = 25;  
print(++y);                 //The prefix value,  
         
var z = 10;  
print(--z);                  //The prefix value  
  
var u = 12;                                           
   print(u--);     //The postfix value  
}          
   
Output:
30
26
9
12

3. Assignment Operator

Example -
void main(){  
 print("Example of Assignment operators");  
    
  var n1 = 10;  
  var n2 = 5;  
    
  n1+=n2;  
  print("n1+=n2 = ${n1}");  
    
  n1-=n2;  
  print("n1-=n2 = ${n1}");  
    
  n1*=n2;  
  print("n1*=n2 = ${n1}");  
    
  n1~/=n2;  
  print("n1~/=n2 = ${n1}");  
  n1%=n2;  
  print("n1%=n2 = ${n1}");    
}  

Output:
Example of Assignment operators 
n1+=n2 = 15 
n1-=n2 = 10 
n1*=n2 = 50 
n1~/=n2 = 10 
n1%=n2 = 0 

4. Relational Operator

Example -
void main() {   
var a = 30;  
var b = 20;  
  
print("The example of Relational Operator");  
  
var res = a>b;  
print("a is greater than b: "+res. toString());  // We will learn the toString in next tutorial  
  
var res0 = a<b;  
print("a is less than b: "+res0. toString());  
  
var res1 = a>=b;  
print("a is greater than or equal to b: "+res1. toString());  
  
var res2 = a<=b;  
print("a is less than and equal to b: "+res2. toString());  
  
var res3 = a!= b;  
print("a is not equal to  b: "+res3. toString());  
  
var res4 = a==b;  
print("a is  equal to  b: "+res4. toString());  
}  

Output:
The example of Relational Operator
a is greater than b: true
a is less than b: false
a is greater than or equal to b: true
a is less than and equal to b: false
a is not equal to  b: true
a is  equal to  b: false

5. Type Test Operators

Example:
void main()  
{  
  var num = 10;  
  var name = "JavaTpoint";  
  print(num is int);    
  print(name is! String );  
} 

Output:
true
false

6. Logical Operators

Example:
void main(){  
  bool bool_val1 = true, bool_val2 = false;   
  print("Example of the logical operators");  
    
  var val1 = bool_val1 && bool_val2;  
  print(val1);  
    
  var val2 = bool_val1 || bool_val2;  
  print(val2);  
    
  var val3 = !(bool_val1 || bool_val2);  
  print(val3);   
}  

Output:
false 
true 
false

7. Bitwise Operators

Example -
void main(){  
  print("Example of Bitwise operators");  
    
  var a  = 25;  
  var b = 20;  
  var c = 0;  
    
  // Bitwise AND Operator  
  print("a & b = ${a&b}");  
    
  // Bitwise OR Operator  
  print("a | b = ${a|b}");  
    
  // Bitwise XOR  
  print("a ^ b = ${a^b}");  
    
  // Complement Operator  
  print("~a = ${(~a)}");  
    
  // Binary left shift Operator  
  c = a <<2;  
  print("c<<1= ${c}");  
    
  // Binary right shift Operator  
  c = a >>2;  
  print("c>>1= ${c}");  
}  

Output:
a & b = 16
 a | b = 29
 a ^ b = 13
 ~a = 4294967270
 c<<1= 100
 c>>1= 6

8. Conditional Operators (?:)

Example -
void main() {   
   var x = null;   
   var y = 20;   
   var val = x ?? y;   
   print(val);   
}  

Output:
20

or operator in dart

var a = 10 
var result = ( a>5 || a<10)

dart ?? operator

String? foo = null;

print(foo ?? " its empty");//output: ' its empty'

foo = "foo";

print(foo ?? " its empty");//output: "foo"

dart is operator

void main() {
  
  dynamic variable = "hello";
  
  if(variable is String) {
    print("is a String");
  } else {
    print("is not String");
  }
 
  if(variable is int) {
    print("is a int");
  } else {
    print("is not int");
  }
    
}

dart .. operator

void main() {
  Person()
    ..name = "John"
    ..age = 30
    ..sex = "Male"
    ..describeMyself();
}

class Person {
  String? name;
  int? age;
  String? sex;

  Person({this.name, this.age, this.sex});

  void describeMyself() {
    print('Hello my name is $name, I am $age years old');
  }
}

dart operator ??

String? foo = null;

print(foo ?? " its empty");//output: ' its empty'

foo = "foo";

print(foo ?? " its empty");//output: "foo"

dart ?? operator

??

Called also null operator. This operator returns expression on its left, except if it is null, and if so, it returns right expression:

void main() {
  print(0 ?? 1);  // <- 0
  print(1 ?? null);  // <- 1
  print(null ?? null); // <- null
  print(null ?? null ?? 2); // <- 2
}

C++相关代码片段

how to kill

hello world cpp

cpp hello world

when kotlin

how to write hello world c++

fenwick tree

main function

python loop

is palindrom

subsequence

insertion sort

react cookie

data structure

Stack Modified

increment integer

496. Next Greater Element I.cpp

c++ freecodecamp course 10 hours youtube

simple interest rate

deliberation meaning

fingerprint

c++ system() from variable

operator using

unambiguous

Stream Overloading

quick_sort

hash table

graph colouring

the question for me

fname from FString

how togreper

is plaindrome

logisch oder

robot framework for loop example

spyder enviroment

pallindrome string

ue4 c++ string from fvector

interactive problem

two sum solution

interpolation search

Required Length

new expression

Targon lol

xor linked list

stack implementation

typescript

loop through array

loop array

how to point to next array using pointer c++

file exist

floating point exception

array di struct

castin in C++

varint index

how to make a instagram report bot python

windows servis from console app

add integers

listas enlazadas/ linked lists

niet werkend

bubble sort

triangle angle sum

divisor summation

rotateArray

destiny child

Populating Next Right Pointers in Each Node

cosnt cast

bucket sort

double plus overload

Z-function

binary search

permutation

linked list

Implicit conversion casting

square root

public method

tower of hanoi

selection sort

dangling pointer

hello world programming

statements

volumeof a sphere