jastrachan | 10 Aug 12:08 2004
Picon

Re: [groovy-dev] inverse of contains()


On 6 Aug 2004, at 12:32, Jeremy Rayner wrote:
> Wouldn't it be groovy to have the inverse of the contains() method, on
> Object, such that you could express
>
> ...
> if idColumn.isIn(table.primaryKeyColumns) {

Whats wrong with doing it the normal way

if (table.primaryKeyColumns.contains(idColumn)) {...}

FWIW someone did mention on the wiki somewhere that if we already have 
'in' as a keyword for iteration...

for (x in coll) {... }

then shouldn't we support this for predicates

if (x in coll) {...}

which seems a reasonable suggestion. In this case this would be 
syntactic sugar for

if (coll.contains(x)) {...}

which would not involve a proliferation of new methods on Object etc. 
It oes look simpler & more like the iteration syntax. Thoughts?

James
-------
http://radio.weblogs.com/0112098/


Gmane