Most programmers are familiar with the ternary operator ?: that is available in C and most other languages. But what some people may not know is that you can also use this operator with only two arguments.

Instead of writing

int y = 23;
int x = (y ? y : 34);

you can do this

int y = 23;
int x = (y ?: 34);

The other thing some of you may not know is that when defining a const you can’t use an if statement to define it based on a condition, but you can do this:

int y = 23;
const int x = (y ?: 34);

That’s it for the first post!