One thing that I've always wanted is the ability to create a Map in one line of code. For example, it would allow initialization of a static Map without having to resort to static blocks of code.


I'm thinking of something like:


    createMap(Object[][])
    createMap(Map.Entry[])


Example uses are:


static final Map MAP = createMap(new Object[][] {new Object[] {"key", "value"}, new Object[] {new Integer(1), new Integer(2)}});

static final Map MAP = createMap(new Map.Entry[] {new DefaultMapEntry("key", "value"), new DefaultMapEntry(new Integer(1), new Integer(2)}));


It's a bit ugly, but it could be useful. I think that Perl and some other languages allow map/hash/dictionary objects to be created in this manner.


Would this be a valuable addition to [collections]?


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to