Skip to content

Instantly share code, notes, and snippets.

View kallentu's full-sized avatar
🏔️

Kallen Tu kallentu

🏔️
  • Google
  • 08:59 (UTC -08:00)
View GitHub Profile
class Reader<out T> {
// Compile-time error: Can't use 'out' type variable 'T' in an 'in' position.
void write(T x) => print(x);
// OK
T read() => null;
}
class Writer<in T> {
// Compile-time error: Can't use 'in' type variable 'T' in an 'out' position
// Add a contravariant variance modifier
class Writer<in T> {
void write(T x) => print(x);
}
main() {
// Compile-time error: The constructor returns type 'Writer<int>'
// that isn't of expected type 'Writer<Object>'.
Writer<Object> objectWriter = Writer<int>();
}
class Writer<T> {
void write(T x) => print(x);
}
main() {
Writer<Object> objectWriter = Writer<int>();
objectWriter.write(“I’m a string!”);
}
class MyContravariantClass<in T> {}
mixin MyInvariantMixin<inout T> {}
class ReaderWriter<T> {
void write(T x) => print(x);
T read() => null;
}
main() {
ReaderWriter<int> intRW = ReaderWriter<Object>();
// Any object can be returned, not just integers. This is unsafe.
intRW.read();
main() {
// ...
// Runtime error!
// Unhandled exception: type 'String' is not a subtype of type 'int' of 'x'
objectWriter.write("Hello world!");
}
class Writer<T> {
void write(T x) => print(x);
}
main() {
Writer<Object> objectWriter = Writer<int>();
objectWriter.write(2);
}
main() {
Iterable<Object> objectIterable = <int>[1, 2, 3];
}
@kallentu
kallentu / index.html
Created July 29, 2016 03:58
Tribute to Monty Oum
<link href='https://fonts.googleapis.com/css?family=Pontano+Sans' rel='stylesheet' type='text/css'>
<div class="container jumbotron">
<div class="text-center col-md-12">
<h1>Monty Oum</h1>
<h3><em>Influential Animator and DDR Master</em></h3>
<img class="monty-image" alt="Monty" src="https://upload.wikimedia.org/wikipedia/commons/c/c2/Monty_Oum_at_PAX_2013.jpg">
</div>
<p class= "text-justify col-xs-12 col-md-8 col-md-offset-2 col-sm-10 col-sm-offset-3">Monty Oum was a self-taught animator who worked at Rooster Teeth, making animations for <em>Red Vs. Blue</em>. Afterwards, he created the animated series <em>RWBY</em>. He was occasionally on the RoosterTeeth podcasts and RTLife videos. Visit his <a href="http://roosterteeth.wikia.com/wiki/Monty_Oum">RTWikia</a> for more information.</p>
<div class="text-center col-xs-12 col-md-8 col-md-offset-2 col-sm-10 col-sm-offset-3">
<h3>Filmography</h3>