by
3 4
0
3
345
0
Top 5% !
Popular
Specified
Popularity: 1227890th place

Published on:

No tags for this snippet yet.
LanguageScala
SourceGitHub
SourceMyGists

Array Covariance

Array Covariance: 
ArrayCovariance.scala
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1697343/Array-Covariance?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
// 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
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus