Created
June 20, 2019 17:09
-
-
Save masters3d/3be398a9a16a3ef1d32efdbe5ac29445 to your computer and use it in GitHub Desktop.
Default Init for Swift 5.0
This file contains hidden or 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 Initializable { | |
init() | |
} | |
extension String:Initializable {} | |
struct Default<T> where T:Initializable { | |
typealias SomeType = T | |
static func some() -> SomeType { | |
return SomeType() | |
} | |
} | |
var x:String = Default.some() | |
print(x + "hey") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment