Allow values of your type to be expressed using different kinds of literals.
Initialization with Literals
Topics
Collection Literals
protocol Expressible By Array LiteralA type that can be initialized using an array literal.
protocol Expressible By Dictionary LiteralA type that can be initialized using a dictionary literal.
Value Literals
protocol Expressible By Integer LiteralA type that can be initialized with an integer literal.
protocol Expressible By Float LiteralA type that can be initialized with a floating-point literal.
protocol Expressible By Boolean LiteralA type that can be initialized with the Boolean literals true and false.
protocol Expressible By Nil LiteralA type that can be initialized using the nil literal, nil.
String Literals
protocol Expressible By String LiteralA type that can be initialized with a string literal.
protocol Expressible By Extended Grapheme Cluster LiteralA type that can be initialized with a string literal containing a single extended grapheme cluster.
protocol Expressible By Unicode Scalar LiteralA type that can be initialized with a string literal containing a single Unicode scalar value.
protocol Expressible By String InterpolationA type that can be initialized by string interpolation with a string literal that includes expressions.
protocol String Interpolation ProtocolRepresents the contents of a string literal with interpolations while it’s being built up.
struct Default String InterpolationRepresents 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.