Skip to content

Instantly share code, notes, and snippets.

@FabP93
Last active April 16, 2020 19:03
Show Gist options
  • Save FabP93/418dcae1fcbe360a45f7e82528492acb to your computer and use it in GitHub Desktop.
Save FabP93/418dcae1fcbe360a45f7e82528492acb to your computer and use it in GitHub Desktop.
Mixing generics and Subtypes Part 2
struct Activity<T> {}
var pushup = Activity<Pushup>()
// You can't do this, it raises the error:
// Cannot assign value of type 'Activity<Pushup>' to type 'Activity<Exercise>'
var activity: Activity<Exercise> = pushup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment