groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: New syntax explosion
Date Fri, 06 Oct 2017 16:27:41 GMT
On 06.10.2017 09:11, Mauro Molinari wrote:
[...]
>> x = a?.b?.c?.d
>>
>> is translated as:
>>
>> var tmp
>> tmp = a==null?null: a.b
>> tmp = tmp==null?null: tmp.c
>> tmp = tmp==null?null: tmp.d
>> x = tmp [cut]
>> while x = a??.b.c.d is
>>
>> var tmp
>> tmp = a==null?null: a.b.c.d
>> x = tmp
>>
> So are you saying that "a??.b.c" is NOT equivalent to "a?.b?.c"? With 
> this implementation of  "??", a NPE is thrown if a is not null but a.b 
> is...

with this implementation we talk about my example here. That is not what 
is implemented right now. May pint is that in my version the null check 
stops the evaluation of the remaining expression, while the current ??. 
does it for each part.

bye Jochen

Mime
View raw message