Skip to content

Instantly share code, notes, and snippets.

@PaulWoodIII
Created August 4, 2019 00:02
Show Gist options
  • Select an option

  • Save PaulWoodIII/2ecf93baf09216134eb1b7fca2a822a3 to your computer and use it in GitHub Desktop.

Select an option

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
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