ExpressibleByStringLiteral
A type that can be initialized with a string literal.
protocol ExpressibleByStringLiteral : ExpressibleByExtendedGraphemeClusterLiteral
The String
and StaticString
types conform to the ExpressibleByStringLiteral
protocol. You can initialize a variable or constant of either of these types using a string literal of any length.
let picnicGuest = "Deserving porcupine"
Conforming to ExpressibleByStringLiteral
To add ExpressibleByStringLiteral
conformance to your custom type, implement the required initializer.
Supertypes
protocol ExpressibleByExtendedGraphemeClusterLiteral
A type that can be initialized with a string literal containing a single extended grapheme cluster.
protocol ExpressibleByUnicodeScalarLiteral
A type that can be initialized with a string literal containing a single Unicode scalar value.
Requirements
associatedtype StringLiteralType : _ExpressibleByBuiltinStringLiteral
A type that represents a string literal.
init(stringLiteral: Self.StringLiteralType
) Creates an instance initialized to the given string value.
Citizens in Swift
Subtypes
protocol ExpressibleByStringInterpolation
A type that can be initialized by string interpolation with a string literal that includes expressions.
protocol StringProtocol
A type that can represent a string as a collection of characters.
Extension in SwiftSyntaxBuilder
Subtypes
protocol SyntaxExpressibleByStringInterpolation
Syntax nodes that can be formed by a string interpolation involve source code and interpolated syntax nodes.