Hi Markus,

There is already an array operator defined in Wonder for isEmpty: @isEmpty

With the current NSArray key value coding handling, there is only a single 
exception to the rule that pass the key to array values, it is for the "count" 
key.

There is already 2 way to get the if "array.isEmpty" : by using a <wo:not 
condition = "array.count">   or by using <wo:if condition = "array.@isEmpty"> 
and there is an ERXKey for this operator like Contact.ADDRESSES.atIsEmpty().

I think adding this exception could make thing more clear and I do not thing 
there would be code break, an array of boolean for the emptiness of a array 
inside does not seem very useful unlike an array of real values...

But as there is already other ways to achieve the same result, I vote to keep 
thing as is.

Regards,

Samuel

> Le 14 mai 2018 à 08:17, Markus Ruggiero <mailingli...@kataputt.com> a écrit :
> 
> 
>> On 14 May 2018, at 12:17, Johann Werner <johann.wer...@posteo.de> wrote:
>> 
>> Hi Markus,
>> 
>> aligning isEmpty to mimic count in KVC context is a logic step but I would 
>> advise against it as changing that behavior could silently break code of 
>> many projects.
>> 
>> A far better implementation could have been to route all KVC calls to the 
>> NSArray object itself and introduce something like @items if you want the 
>> KVC to evaluate on every contained item. At least that would be more 
>> expressive.
>> 
>> jm2c
>> 
>> jw
>> 
> 
> 
> Valid point. 
> 
> I have long ago fixed this once in my WonderSources and used this in my 
> Learning The Wonders book. Of course, this was a mistake on my side (or maybe 
> just an "oversight"). But just the other day I got a mail from someone 
> working through the book and getting stuck on isEmpty (example at end of 
> chapter 11)
> 
> For the time being I'll go with my private patch. Maybe others have different 
> viewpoint.
> 
> ---markus---
> 
>> 
>>> Am 14.05.2018 um 10:54 schrieb Markus Ruggiero <mailingli...@kataputt.com>:
>>> 
>>> NSArray implements java.util.List
>>> This interface specifies the method boolean isEmpty() and NSArray correclty 
>>> implements it.
>>> 
>>> Unfortunately key-value-coding does not know about this. When using isEmpty 
>>> in a binding (eg. WOConditional) the key "isEmpty" is not trapped but 
>>> passed on to all the objects. 
>>> 
>>> isEmpty should be trapped in NSArray.java in the same way count() is 
>>> handled.
>>> 
>>> What do you think? 
>>> 
>>> ---markus---
>> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
> 
> This email sent to sam...@samkar.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to