<!--
{
  "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/init(booleanLiteral:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sb14booleanLiteralS2b_tcfc"
  },
  "title" : "init(booleanLiteral:)"
}
-->

# init(booleanLiteral:)

Creates an instance initialized to the specified Boolean literal.

```
init(booleanLiteral value: Bool)
```

## Parameters

`value`

The value of the new instance.

## Discussion

Do not call this initializer directly. It is used by the compiler when
you use a Boolean literal. Instead, create a new `Bool` instance by
using one of the Boolean literals `true` or `false`.

```
var printedMessage = false

if !printedMessage {
    print("You look nice today!")
    printedMessage = true
}
// Prints "You look nice today!"
```

In this example, both assignments to the `printedMessage` variable call
this Boolean literal initializer behind the scenes.

---

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)