Operator

# Or

<div class="rst-class">

forsearch

</div>

Operator

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to perform a logical <span class="title-ref">Or</span> comparison between two `Boolean</api/data_types/boolean>` expressions <span class="title-ref">Or</span> a bitwise <span class="title-ref">Or</span> comparison between two `integers</api/data_types/integer>`.

## Usage

``` xojo
result = expression1 Or expression2
```

| Part        | Type                                                                     | Description                                                                                                                                                                                                                                |
|-------------|--------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| result      | `Boolean</api/data_types/boolean>` or `Integer</api/data_types/integer>` | A `Boolean</api/data_types/boolean>` value if *expression1* and *expression2* are `boolean</api/data_types/boolean>` and an `integer</api/data_types/integer>` if *expression1* and *expression2* are `integers</api/data_types/integer>`. |
| expression1 | `Boolean</api/data_types/boolean>` or `Integer</api/data_types/integer>` | Any valid `Boolean</api/data_types/boolean>` or `integer</api/data_types/integer>` expression. *Expression1* and *expression2* must be of the same data type.                                                                              |
| expression2 | `Boolean</api/data_types/boolean>` or `Integer</api/data_types/integer>` | Any valid `Boolean</api/data_types/boolean>` or `integer</api/data_types/integer>` expression. *Expression1* and *expression2* must be of the same data type.                                                                              |

## Notes

The <span class="title-ref">Or</span> operator is overloaded. If it is passed two `booleans</api/data_types/boolean>`, it performs a logical <span class="title-ref">Or</span> and returns a `boolean</api/data_types/boolean>`. If it is passed two `integers</api/data_types/integer>`, it performs a bitwise <span class="title-ref">Or</span> operation on the `integers</api/data_types/integer>` and returns an `integer</api/data_types/integer>`. In this case, it is equivalent to calling the BitOr method of the `Bitwise</api/language/bitwise>` class.

In the first instance, if either boolean expression evaluates to `True</api/language/true>`, then *result* is `True</api/language/true>`. If both expressions evaluate to `False</api/language/false>` then *result* is `False</api/language/false>`. The truth table for logical operators is shown below.

| Expression1 | Expression2 | Or    | `And</api/language/operators/bitwise_logical/and>` | `Xor</api/language/operators/bitwise_logical/xor>` |
|-------------|-------------|-------|----------------------------------------------------|----------------------------------------------------|
| True        | True        | True  | True                                               | False                                              |
| True        | False       | True  | False                                              | True                                               |
| False       | True        | True  | False                                              | True                                               |
| False       | False       | False | False                                              | False                                              |

If you pass two `integers</api/data_types/integer>`, <span class="title-ref">Or</span> returns an `integer</api/data_types/integer>` that is the result of comparing each bit of the two `integers</api/data_types/integer>` passed and assigning 1 to the bit position in the `integer</api/data_types/integer>` returned if either of the bits in the same position in the `integers</api/data_types/integer>` passed are 1. Otherwise, 0 is assigned to the bit position.

The following table shows the results for bitwise operators:

| Integer1 | Integer2 | Or  | `And</api/language/operators/bitwise_logical/and>` | `Xor</api/language/operators/bitwise_logical/xor>` |
|----------|----------|-----|----------------------------------------------------|----------------------------------------------------|
| 0        | 0        | 0   | 0                                                  | 0                                                  |
| 0        | 1        | 1   | 0                                                  | 1                                                  |
| 1        | 0        | 1   | 0                                                  | 1                                                  |
| 1        | 1        | 1   | 1                                                  | 0                                                  |

## Sample code

This example uses the <span class="title-ref">Or</span> operator to perform logical comparisons

``` xojo
Var a As Boolean
Var b As Boolean
Var c As Boolean
Var d As Boolean
a = True
b = False
d = a Or b ' d = True
d = b Or c ' d = False
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Using <span class="title-ref">Or</span> with Integer values:

``` xojo
Var i1 As Integer = 4
Var i2 As Integer = 5

Var result As Integer
result = i1 Or i2 ' result = 5
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`And</api/language/operators/bitwise_logical/and>`, `Not</api/language/operators/bitwise_logical/not>`, `Xor</api/language/operators/bitwise_logical/xor>` operators; `Bitwise</api/language/bitwise>` class; `Operator Or</api/language/operators/operator_overloads/operator_or>` function; `Operator precedence</api/language/operators/operator_precedence>`

</div>
