# Method `|()

Method `|

  ``mixed` `|(`mixed` `arg1`)`
  ``mixed` `|(`mixed` `arg1`, `mixed` `arg2`, `mixed` ... `extras`)`
  ``mixed` `|(`object` `arg1`, `mixed` `arg2`)`
  ``mixed` `|(`mixed` `arg1`, `object` `arg2`)`
  ``int` `|(`int` `arg1`, `int` `arg2`)`
  ``string` `|(`string` `arg1`, `string` `arg2`)`
  ``array` `|(`array` `arg1`, `array` `arg2`)`
  ``mapping` `|(`mapping` `arg1`, `mapping` `arg2`)`
  ``multiset` `|(`multiset` `arg1`, `multiset` `arg2`)`
  ``type` `|(`program`|`type` `arg1`, `program`|`type` `arg2`)`

Description

  Bitwise or/union.

  Every expression with the `|` operator becomes a call to this function, i.e. `a|b` is the same as `predef::`|(a,b)`.

Returns

  If there's a single argument, that argument is returned.

  If there are more than two arguments, the result is: ``|(`|(<code class='reference paramref'>arg1`, <code class='reference paramref'>arg2), @<code class='reference paramref'>extras).

  Otherwise, if `arg1` is an object with an lfun::`|(), that function is called with `arg2` as argument, and its result is returned.

  Otherwise, if `arg2` is an object with an lfun::``|(), that function is called with `arg1` as argument, and its result is returned.

  Otherwise the result depends on the argument types:

  `arg1` can have any of the following types:

  ``int`` | Bitwise or of `arg1` and `arg2`.
  ``string`` | The result is a string where each character is the bitwise or of the characters in the same position in `arg1` and `arg2`. The arguments must be strings of the same length.

  ``array``

  The result is an array with the elements in `arg1` concatenated with those in `arg2` that doesn't occur in `arg1` (according to `==). The order between the elements that come from the same argument is kept.

  Every element in `arg1` is only matched once against an element in `arg2`, so if `arg2` contains several elements that are equal to each other and are more than their counterparts in `arg1`, the rightmost remaining elements in `arg2` are kept.

  ``mapping`` | The result is like `arg1` but extended with the entries from `arg2`. If the same index (according to hash_value and `==) occur in both, the value from `arg2` is used.
  ``multiset`` | The result is like `arg1` but extended with the entries in `arg2` that doesn't already occur in `arg1` (according to `==). Subsequences with orderwise equal entries (i.e. where `< returns false) are handled just like the array case above.
  ``type`|`program`` | Type union of `arg1` and `arg2`.

  The function is not destructive on the arguments - the result is always a new instance.

See also

  `&(), lfun::`|(), lfun::``|()