Allow values of your type to be expressed using different kinds of literals.
Initialization with Literals
Topics
Collection Literals
protocol Expressible By Array Literal
A type that can be initialized using an array literal.
protocol Expressible By Dictionary Literal
A type that can be initialized using a dictionary literal.
Value Literals
protocol Expressible By Integer Literal
A type that can be initialized with an integer literal.
protocol Expressible By Float Literal
A type that can be initialized with a floating-point literal.
protocol Expressible By Boolean Literal
A type that can be initialized with the Boolean literals true
and false
.
protocol Expressible By Nil Literal
A type that can be initialized using the nil literal, nil
.
String Literals
protocol Expressible By String Literal
A type that can be initialized with a string literal.
protocol Expressible By Extended Grapheme Cluster Literal
A type that can be initialized with a string literal containing a single extended grapheme cluster.
protocol Expressible By Unicode Scalar Literal
A type that can be initialized with a string literal containing a single Unicode scalar value.
protocol Expressible By String Interpolation
A type that can be initialized by string interpolation with a string literal that includes expressions.
protocol String Interpolation Protocol
Represents the contents of a string literal with interpolations while it’s being built up.
struct Default String Interpolation
Represents a string literal with interpolations while it is being built up.
Default Types for Literals
Type aliases representing the concrete type that a literal takes when no other type information is provided.
See Also
Tools for Your Types
Use your custom types in operations that depend on testing for equality or order and as members of sets and dictionaries.
Serialize and deserialize instances of your types with implicit or customized encoding.