Skip to content

Instantly share code, notes, and snippets.

@kallentu
Last active December 19, 2019 17:26
Show Gist options
  • Save kallentu/6f672eb3518dc9bf6ee1fbb640cbdad8 to your computer and use it in GitHub Desktop.
Save kallentu/6f672eb3518dc9bf6ee1fbb640cbdad8 to your computer and use it in GitHub Desktop.
class Writer<in T> {
void write(T value) => print(value);
}
class Reader<out T> {
final T value;
Reader(this.value);
T read() => value;
}
main() {
Writer<int> intWriter = Writer<Object>();
intWriter.write(2);
Reader<Object> objectReader =
Reader<String>("Wow, this is soundly variant!");
print(objectReader.value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment