Created
April 30, 2016 09:45
-
-
Save luish/0f5b456323bbdb3366293cf862a3fefb 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
protocol StringType {} | |
extension String: StringType {} | |
extension Optional where Wrapped: StringType { | |
var something: Int { | |
switch self { | |
case .None: return 10 | |
case .Some(_): return 20 | |
} | |
} | |
} | |
let str: String? = nil | |
print(str.something) // 10 | |
let str2: String? = "abc" | |
print(str2.something) // 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment