Shadow Of Shadow Of - 3 months ago 20
Swift Question

Custom literal method with LiteralConvertible

I am reading about

LiteralConvertible
protocols (lets take
StringLiteralConvertible
for example), and I found that in swift 1.2 you can use implicit typecasting from literal to your custom
LiteralConvertible
type. Following example taken from NSHipster blog:

struct SomeStruct: StringLiteralConvertible {
init(stringLiteral value: String) {}
init(extendedGraphemeClusterLiteral value: String) {}
init(unicodeScalarLiteral value: String) {}
func someFunc(){}
}


Somewhere in executable space:

let someStruct: SomeStruct = "

Answer

It wouldn't make sense, w.r.t. type safety and non-ambiguity, if the last row ("