#
`|`

(union) operator

The left-associative, binary infix `|`

operator is used to compute the
*union* of two operands.

## Usage

Union on values:

```
void m(Set<Integer> odds, Set<Integer> evens) {
Set<Integer> ints = odds | evens;
}
```

## Description

**Note**: The `|`

operator is also commonly used to
union types.
This page is about using the `|`

operator on values.

### Definition

The `|`

operator is defined as follows:

```
lhs.union(rhs)
```

See the language specification for more details.

### Polymorphism

The `|`

operator is polymorphic.
The meaning of `|`

depends on the
`Set`

interface

### Type

The result type of the `|`

operator is a `Set`

whose element type is the union of the
element types of its operands.

## See also

- API documentation for
`Set`

- set operators in the language specification
- operator precedence in the language specification
- Operator polymorphism