Skip to content

Instantly share code, notes, and snippets.

@jrsonline
Last active January 28, 2018 03:11
Show Gist options
  • Save jrsonline/731b43af8a8efcab0fc572d874329950 to your computer and use it in GitHub Desktop.
Save jrsonline/731b43af8a8efcab0fc572d874329950 to your computer and use it in GitHub Desktop.
// suppose we have some class
class AClass<A> { required init() {} }
// we can certainly create a generic type using that class
// note that we are "hard coding" creating an AClass object
struct GenericType<A> { var a = AClass<A>() }
let ta = Type<Int>()
// ...but we can't tell Swift what sort of object to create
// eg we cannot be generic in the 'AClass'
// the T<A>() doesn't work
// ie: we can't generalize the Type Constructor T<A>()
struct HigherType<T : AClass,A> { var a = T<A>() }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment