ExpressibleByExtendedGraphemeClusterLiteral

protocol ExpressibleByExtendedGraphemeClusterLiteral

A type that can be initialized with a string literal containing a single extended grapheme cluster.

An extended grapheme cluster is a group of one or more Unicode code points that approximates a single user-perceived character. Many individual characters, such as "é", "김", and "🇮🇳", can be made up of multiple Unicode code points. These code points are combined by Unicode's boundary algorithms into extended grapheme clusters.

The String, StaticString, and Character types conform to the ExpressibleByExtendedGraphemeClusterLiteral protocol. You can initialize a variable or constant of any of these types using a string literal that holds a single character.

let snowflake: Character = "❄︎"
print(snowflake)
// Prints "❄︎"

Conforming to ExpressibleByExtendedGraphemeClusterLiteral

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

Inheritance ExpressibleByUnicodeScalarLiteral View Protocol Hierarchy →
Associated Types
ExtendedGraphemeClusterLiteralType

A type that can represent an extended grapheme cluster literal.

Valid types for ExtendedGraphemeClusterLiteralType are Character, String, and StaticString.

UnicodeScalarLiteralType

A type that can represent a Unicode scalar literal.

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

Import import Swift

Initializers

init(extendedGraphemeClusterLiteral:) Required

Creates an instance initialized to the given value.

Declaration

init(extendedGraphemeClusterLiteral value: Self.ExtendedGraphemeClusterLiteralType)
init(unicodeScalarLiteral:) Required

Creates an instance initialized to the given value.

Declaration

init(unicodeScalarLiteral value: Self.UnicodeScalarLiteralType)

Declared In

ExpressibleByUnicodeScalarLiteral