On Thu, 2008-10-16 at 10:02 -0700, Robert Greayer wrote:
>
>
> --- On Thu, 10/16/08, Jonathan Cast <[EMAIL PROTECTED]> wrote:
>
> > Can I have HashSet<Integer>? Could I construct
> > HashSet<?>, if I did?
>
> Yes:
>
> HashSet<?> blah = (HashSet<?>) hashSetClass.newInstance();
>
> ... compiles, and won't throw an exception if hashSetClass truly is
> the class object for HashSet.
But I can't say new HashSet<?>()?
> Pretty useless, because you can't put anything *into* a HashSet<?>
> object...
Even if my client hands my a ? object?
> blah.add("foo"); // doesn't typecheck...
>
> but you can do:
> HashSet<String> blah = (HashSet<String>) hashSetClass.newInstance();
> blah.add("foo");
>
> works fine..
jcc
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe