Author Login
Post Reply
I have a map of maps, so that it can be used like a generalization of a 2D
array; i.e.
def map = ['a':['b':'c'], 'd':['e':'f']]
I want to use the safe dereference operator, but it does not work with the
subscript operator. In other words, I want to do this;
if (map['a']?['b'] != null) {
// process map['a']['b']
}
But this does not work. Instead, I do this:
if (map.getAt('a')?.getAt('b') != null) {
// process map['a']['b']
}
This works, but is a little wordy, and it seems like since getAt is what the
subscript operator is translated to, the top line should work. Is there a
shorter syntax for what I want to do?
Thanks,
Dave
--
Sent from the groovy - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email