Ternary that recognises polymorphism
My suggestion (quite simply!) is to make the following acceptable: -
boolean iNeedAVector = true;
List l = (iNeedAVector) ? new ArrayList() : new Vector();
Since the ternary always evaluates to a List, why is this not acceptable? I would suggest that the following should also work (for the same reasons): -
boolean iNeedAString = true;
Object o = (iNeedAString) ? "string" : new Integer(1);
What do you guys think?