Skip to content

Instantly share code, notes, and snippets.

@koher
Created May 14, 2017 22:07
Show Gist options
  • Save koher/2a5a817e1528e72549c45e1fbe06f553 to your computer and use it in GitHub Desktop.
Save koher/2a5a817e1528e72549c45e1fbe06f553 to your computer and use it in GitHub Desktop.
open class Animal
class Cat: Animal()
class Box<out Value> ( // `out` for covariance
val value: Value
)
fun main(args: Array<String>) {
val catBox: Box<Cat> = Box(Cat())
val animalBox: Box<Animal> = catBox // OK
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment