Skip to content

Instantly share code, notes, and snippets.

@kallentu
Last active December 19, 2019 18:14
Show Gist options
  • Save kallentu/96ac944929419eb1992ddeed97a776b6 to your computer and use it in GitHub Desktop.
Save kallentu/96ac944929419eb1992ddeed97a776b6 to your computer and use it in GitHub Desktop.
class Reader<out T> {
// Compile-time error: Can't use 'out' type variable 'T' in an 'in' position.
T readableWritableValue;
// OK
final T readableValue;
}
class Writer<in T> {
// Compile-time error: Can't use 'in' type variable 'T' in an 'out' position.
T readableWritableValue;
// Compile-time error: Can't use 'in' type variable 'T' in an 'out' position.
final T readableValue;
}
class ReaderWriter<inout T> {
// Both OK
T readableWritableValue;
final T readableValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment