Created
August 4, 2019 00:02
-
-
Save PaulWoodIII/2ecf93baf09216134eb1b7fca2a822a3 to your computer and use it in GitHub Desktop.
A sneaky addition, we can use generics to help us write this initializer for all types of Nameable
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
| struct NameHolder: Nameable { | |
| var id: String { return name } | |
| var name: String | |
| init<U>(nameable name: U) where U: Nameable { | |
| self.name = name.name | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment