In Python I can do the following:
d = { 'a': True, 'b': False }
print d.get('x', True)
It will print
True
In Java, the HashMap.get method does not have the second argument for specifying a default value. What is a correct, terse and readable way of achieving this? The following expression seems too redundant to me:
map.containsKey("x") ? map.get("x") : true