protocol
ExpressibleByUnicodeScalarLiteral
A type that can be initialized with a string literal containing a single Unicode scalar value.
Conforming Types | ExpressibleByExtendedGraphemeClusterLiteral, StaticString, Substring, Unicode.Scalar |
---|---|
Associated Types |
|
The String
, StaticString
, Character
, and Unicode.Scalar
types all
conform to the ExpressibleByUnicodeScalarLiteral
protocol. You can
initialize a variable of any of these types using a string literal that
holds a single Unicode scalar.
let
ñ:
Unicode.Scalar
=
"ñ"
(ñ)
// Prints "ñ"
Conforming to ExpressibleByUnicodeScalarLiteral
To add ExpressibleByUnicodeScalarLiteral
conformance to your custom type,
implement the required initializer.
Initializers
Creates an instance initialized to the given value.
- Parameter value: The value of the new instance.
Declaration
init
(
unicodeScalarLiteral
value
:
Self
.
UnicodeScalarLiteralType
)
Valid types for
UnicodeScalarLiteralType
areUnicode.Scalar
,Character
,String
, andStaticString
.