Proposal: Elvis and Other Null-Safe Operators

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


Hello!

I need add something
MAJOR ADVANTAGE:

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" : member.name;

__ 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
right-hand-side

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ł

http://lasu2string.blogspot.com/



More information about the coin-dev mailing list