Proposal: Elvis and Other Null-Safe Operators

Marek Kozieł develop4lasu at
Sun Mar 1 10:39:25 PST 2009


I need add something

It's multi-thread safe.

Same goal for:

 final String aMember = g?.members?[0]?.name ?: "nobody";

would require for example:

static String getBody(G g){

__ Member[] members = g==null ? null : g.members;

__ Member member = members==null ? null : members[0];

__ String name = member==null ? "nobody" :;

__ return name;


 final String aMember = g?.members?[0]?.name ?: "nobody";

>The ?: binary "Elvis" ... avoiding evaluation of the right-hand-side.

I would like to see this operator more like: '?()' this would allow

int len =g?.members?.[0]?.name ?("nobody") .length;

I still wander how this operator should look like to be really easy to read
'.?.' or '?.' or '?..'.

Pozdrowionka. / Regards.
Lasu aka Marek Kozieł

More information about the coin-dev mailing list