<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Bool/__(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Operator",
  "symbol" : {
    "kind" : "Operator",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sb2oooiyS2b_SbyKXKtKFZ"
  },
  "title" : "||(_:_:)"
}
-->

# ||(_:_:)

Performs a logical OR operation on two Boolean values.

```
static func || (lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows -> Bool
```

## Parameters

`lhs`

The left-hand side of the operation.

`rhs`

The right-hand side of the operation.

## Discussion

The logical OR operator (`||`) combines two Boolean values and returns
`true` if at least one of the values is `true`. If both values are
`false`, the operator returns `false`.

This operator uses short-circuit evaluation: The left-hand side (`lhs`) is
evaluated first, and the right-hand side (`rhs`) is evaluated only if
`lhs` evaluates to `false`. For example:

```
let majorErrors: Set = ["No first name", "No last name", ...]
let error = ""

if error.isEmpty || !majorErrors.contains(error) {
    print("No major errors detected")
} else {
    print("Major error: \(error)")
}
// Prints "No major errors detected"
```

In this example, `lhs` tests whether `error` is an empty string.
Evaluation of the `||` operator is one of the following:

- When `error` is an empty string, `lhs` evaluates to `true` and `rhs` is
  not evaluated, skipping the call to `majorErrors.contains(_:)`. The
  result of the operation is `true`.
- When `error` is not an empty string, `lhs` evaluates to `false` and
  `rhs` is evaluated. The result of evaluating `rhs` is the result of the
  `||` operation.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)