Dart int operator-bitwise-or
Syntax & Examples


int.operator-bitwise-or operator

The `|` operator in Dart performs a bit-wise OR operation between this integer and another integer.


Syntax of int.operator-bitwise-or

The syntax of int.operator-bitwise-or operator is:

operator |(int other) → int

This operator-bitwise-or operator of int bit-wise or operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredThe other integer to perform the operation with.


✐ Examples

1 Bit-wise OR operation with 5 and 3

In this example,

  1. We assign the values 5 and 3 to the integer variables num1 and num2 respectively.
  2. We perform the bit-wise OR operation between num1 and num2.
  3. We print the result to standard output.

Dart Program

void main() {
  int num1 = 5;
  int num2 = 3;
  int result = num1 | num2;
  print('Result of bit-wise OR operation: $result');
}

Output

Result of bit-wise OR operation: 7

2 Bit-wise OR operation with 10 and 7

In this example,

  1. We assign the values 10 and 7 to the integer variables num1 and num2 respectively.
  2. We perform the bit-wise OR operation between num1 and num2.
  3. We print the result to standard output.

Dart Program

void main() {
  int num1 = 10;
  int num2 = 7;
  int result = num1 | num2;
  print('Result of bit-wise OR operation: $result');
}

Output

Result of bit-wise OR operation: 15

3 Bit-wise OR operation with 12 and 8

In this example,

  1. We assign the values 12 and 8 to the integer variables num1 and num2 respectively.
  2. We perform the bit-wise OR operation between num1 and num2.
  3. We print the result to standard output.

Dart Program

void main() {
  int num1 = 12;
  int num2 = 8;
  int result = num1 | num2;
  print('Result of bit-wise OR operation: $result');
}

Output

Result of bit-wise OR operation: 12

Summary

In this Dart tutorial, we learned about operator-bitwise-or operator of int: the syntax and few working examples with output and detailed explanation for each example.