Proposal: Elvis and Other Null-Safe Operators
    Stephen Colebourne 
    jodastephen at gmail.com
       
    Sun Apr  5 05:11:57 PDT 2009
    
    
  
Mark Mahieu wrote:
>>
>> List list = null;
>> boolean b = list?.isEmpty() ?: true;
>>
>> Stephen
>>
>
> I don't understand how that combination is supposed to work, given 
> this part of the proposal:
>
> "A null-safe method invocation expression e1?.name(args) ... the type 
> of the result is the same as the type of e1.name(args).  It is an 
> error if this is not a reference type."
>
> Doesn't that mean that the compiler should reject the expression 
> 'list?.isEmpty()' ?
I hope Neal can comment as he wrote up the details of the proposal. I 
did ask him about this when I first read it, and he replied that 
primitives were handled in the "boxedValue ?: primitive" case. At the 
time, I assumed that meant that the "list?.isEmpty() ?: false" was also 
handled, but on re-reading today, you may be right.
I'd like the "list?.isEmpty() ?: false" to be handled though.
Stephen
    
    
More information about the coin-dev
mailing list