commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [collection] Collections for primitives
Date Tue, 25 Jun 2002 18:28:22 GMT
From: "Michael A. Smith" <mas@apache.org>
> > Hm.  Based on what I've just said, it might be defensible for the
> > Predicate and primitive collections to remain as they are.  For
> > the primitive case, it's always exceptional to pass in a non-primitive;
> > but for the predicate case, it may or may not be exceptional to pass
> > in a value that fails the predicate.  Hence the different behaviors.
>
> my point exactly.  :)

I just find this pesky. My use case revolves around me not knowing that its
a primitive collection that I'm querying.

List list = new IntArrayList();
list.add(7);
if (checkForFriendlyLists(list)) {
  // do something
}

public boolean checkForFriendlyLists(List list) {
    return list.contains("Hello!");
}

This is very contrived, I know. But the point is that the second method
might not have been written by you. Its not going to be expecting a
ClassCastException, and thus might not handle it.

Stephen


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message