Feb 21, 2012

[Tips] ?: Operator and ?? Operator

Use "if" condition:
if (condition)
  result = t;
else
  result = f;

if (obj != null)
  result = obj;
else
  result = something;


Use "?:" operator
result = condition ? t : f;


Use "??" operator
result = obj ?? something;

No comments:

Post a Comment