Skip to content

Instantly share code, notes, and snippets.

@toandv
Created June 16, 2016 09:52
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 toandv/6554f7ed9c3294a41d48e4b10a8b8d8e to your computer and use it in GitHub Desktop.
Save toandv/6554f7ed9c3294a41d48e4b10a8b8d8e to your computer and use it in GitHub Desktop.
Array Covariance
// Arrays are covariant in Java, but it's not necessary.
String[] s = new String[2];
Object[] o = s;
o[0] = 1; // ArrayStoreException
// Arrays in Scala are not covariant
val a: Array[NonEmpty] = Array(new NonEmpty(1, Empty, Empty))
val b: Array[IntSet] = a // Compilation error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment