Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AlexZverusha/935adc0f23dae1474b733a0d4b81f3df to your computer and use it in GitHub Desktop.

Select an option

Save AlexZverusha/935adc0f23dae1474b733a0d4b81f3df to your computer and use it in GitHub Desktop.
Generic Subscripts
struct GenericDictionary<Key: Hashable, Value> {
private var data: [Key: Value]
init(data: [Key: Value]) {
self.data = data
}
subscript<T>(key: Key) -> T? {
return data[key] as? T
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment