Skip to content

Instantly share code, notes, and snippets.

@javarouka
Created March 26, 2019 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javarouka/974e7db0b88b616da80cfdec90df62a7 to your computer and use it in GitHub Desktop.
Save javarouka/974e7db0b88b616da80cfdec90df62a7 to your computer and use it in GitHub Desktop.
generics
// Java
interface Source<T> {
T next();
}
void demo(Source<String> strs) {
Source<? extends Object> objects = strs;
}
// @Kotlin
interface Source<out T> {
fun next(): T
}
fun demo(strs: Source<String>) {
val objects: Source<Any> = strs
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment