ExpressibleByUnicodeScalarLiteral

protocol ExpressibleByUnicodeScalarLiteral

A type that can be initialized with a string literal containing a single Unicode scalar value.

The String, StaticString, Character, and UnicodeScalar 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 ñ: UnicodeScalar = "ñ"
print(ñ)
// Prints "ñ"

Conforming to ExpressibleByUnicodeScalarLiteral

To add ExpressibleByUnicodeScalarLiteral conformance to your custom type, implement the required initializer.

Inheritance View Protocol Hierarchy →
Associated Types
UnicodeScalarLiteralType

A type that can represent a Unicode scalar literal.

Valid types for UnicodeScalarLiteralType are UnicodeScalar, String, and StaticString.

Import import Swift

Initializers

init(unicodeScalarLiteral:) Required

Creates an instance initialized to the given value.

Declaration

init(unicodeScalarLiteral value: Self.UnicodeScalarLiteralType)