Created
June 11, 2020 19:45
-
-
Save Wassmd/4154b3cab49c33ca161564a77ee9ac71 to your computer and use it in GitHub Desktop.
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
import UIKit | |
class Widget { | |
let name: String | |
required init(name: String) { | |
self.name = name | |
} | |
} | |
func createWidget<T: Widget>(ofType: T.Type) -> T { | |
let widget = T.init(name: "Roq") | |
return widget | |
} | |
let a = createWidget(ofType: Widget.self) | |
print("\(a.name)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment