Proposal: Elvis and Other Null-Safe Operators (original) (raw)
Stephen Colebourne jodastephen at gmail.com
Thu Mar 19 10🔞32 PDT 2009
- Previous message: Proposal: Elvis and Other Null-Safe Operators
- Next message: Feedback and comments on ARM proposal - resend
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Neal Gafter wrote:
On Thu, Mar 19, 2009 at 1:26 AM, Jacek Kolodziejczyk <jacek.p.kolodziejczyk at gmail.com> wrote:
In my opinion the most obtrusive part in the current state of proposals is assumption that the invocation on null object should always return null. If I understand it correctly the following would break at runtime, because null cannot be assigned to boolean:
List list = null; boolean b = list?.isEmpty(); That would be a compile-time error because of the incompatibility between null and boolean. The intention is that you can write a combination to handle this with the submitted Coin proposal:
List list = null; boolean b = list?.isEmpty() ?: true;
Stephen
- Previous message: Proposal: Elvis and Other Null-Safe Operators
- Next message: Feedback and comments on ARM proposal - resend
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]