jastrachan | 10 Aug 17:40 2004
Picon

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


On 10 Aug 2004, at 16:35, Mark Chu-Carroll wrote:

> n Tue, 10 Aug 2004 11:08:27 +0100, jastrachan@...
> <jastrachan@...> wrote:
>>
>> 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?
>
> I like it very much. In fact, I like it enough that if there's no
> objection, I'm willing to do the work to add it.

Excellent! :)

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


Gmane