What is the ternary operator equivalent to this code snippet?

Advertisement

if(x)
y=a;
else
y=b;

  • y=a?b:x;
  • y=if(x?a:b);
  • y=(x&a)?a:(x&b)?b:0;
  • y=x?a:b;
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment

Share via
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Send this to a friend