On Mon, 30 Jul 2012 21:07:05 +0200, Ricky Clarkson
<[email protected]> wrote:
What hole do you see in Scala and C# if covariance and contravariance
open
holes in type safety? There may well be a problem I don't know of.
In Java if you have a List<String> and you can access it as a
List<Object>, you can put any object inside it:
List<String> ls = new ArrayList<String>();
List<Object> lo = ls; // illegal in Java, suppose it is ok just for now
lo.add(new Date());
String s = ls.get(0); // ClassCastException at runtime.
I don't know about C# and Scala: so somebody please tell me how the
problem above is avoided.
--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
[email protected]
http://tidalwave.it - http://fabriziogiudici.it
--
You received this message because you are subscribed to the Google Groups "Java
Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en.