Last active
February 19, 2019 12:21
-
-
Save mateuszszklarek/a9257928350a5b24e93abb871094447a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Q: ExpressibleByStringLiteral { | |
typealias StringLiteralType = String | |
var question: String | |
init?(_ possibleQuestion: StringLiteralType) { | |
return nil | |
} | |
init(stringLiteral str: StringLiteralType) { | |
self.question = str | |
} | |
} | |
// Swift 4.2 | |
_ = Q("ultimate question") // 'nil' | |
_ = "ultimate question" as Q // Q(question: 'ultimate question') | |
// Swift 5 | |
_ = Q("ultimate question") // Q(question: "ultimate question") | |
_ = "ultimate question" as Q // Q(question: 'ultimate question') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment