protocol
BooleanLiteralConvertible
Inheritance | View Protocol Hierarchy → |
---|---|
Associated Types |
A type that can represent a Boolean literal, such as |
Import |
|
Initializers
Creates an instance initialized to the given Boolean value.
Do not call this initializer directly. Instead, initialize a variable or
constant using one of the Boolean literals true
and false
. For
example:
let
twasBrillig
=
true
In this example, the assignments to the twasBrillig
constant calls this
Boolean literal initializer behind the scenes.
value
: The value of the new instance.
Declaration
init
(
booleanLiteral
value
:
Self
.
BooleanLiteralType
)
A type that can be initialized with the Boolean literals
true
andfalse
.Only three types provided by Swift---
Bool
,DarwinBoolean
, andObjCBool
---are treated as Boolean values. Expanding this set to include types that represent more than simple Boolean values is discouraged.To add
BooleanLiteralConvertible
conformance to your custom type, implement theinit(booleanLiteral:)
initializer that creates an instance of your type with the given Boolean value.