Shadow Of Shadow Of - 8 months ago 63
Swift Question

Custom literal method with LiteralConvertible

I am reading about

protocols (lets take
for example), and I found that in swift 1.2 you can use implicit typecasting from literal to your custom
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 = "


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