list literal gotcha and suggestion

Schulz, Stefan schulz at
Wed Sep 30 05:47:50 PDT 2009

Stephen wrote:
> List<String> list = {"1", "2", "3"} - List literal
> Map<Integer, String> list = {1 : "1", 2 : "2", 3 : "3"} - Map literal
> No set literal
> (I don't think this conflicts with the array literals...)

Just wanted to add a little side-note that, despite not being technically confusable with Lists, Map literals would behave exactly like Sets wrt. duplicate keys. I'd rather prefer clearly typed factory methods over potentially confusing literals in the language. The only really awkward thing regarding creation to me are Maps.

Cheers, Stefan

More information about the coin-dev mailing list