Peter Duniho wrote:
[... in re get(Object) on a Map<K,V> ...]
I see a particular benefit in constraining the
argument; in particular, it allows one at compile time to avoid
writing code that you know will always fail. So there must be some
other benefit that offsets that one, justifying the current design.
Maybe the debate is about this word "fail." In one sense,
if you look for something in a Collection that doesn't contain
it, the search "fails." In another sense, it "succeeds" in
determining the absence of the sought object. It is not a
given that finding something in a Map is the "normal" case and
finding that it's not there is a "failure." An result of "not
there" can even be the desired outcome: Imagine a demolition
foreman checking for people in the building before firing the
explosives to bring the thing down.
A negative answer is not ipso facto a "failure." Yes, it
is a Good Thing to prevent failures -- but that's not the same
thing as preventing negative answers.
isn't a Class.