The ?: operator
You sure know all the operator `?:`. With this operator the code snippet
[code language="objc"]
int x;
if (y) {
x = y;
} else {
x = z;
}
[/code]
is equivalent to
[code language="objc"]
int x = y ? y : z;
[/code]
But did you know that you can write that even shorter? When you look at the last code snippet the condition (`y`) is the same as the value we want to assign to `x`. In this case this can be written as
[code language="objc"]
int x = y ?: z;
[/code]
And this is good because as a software developer you Don't want to Repeat Yourself (the DRY principle).
Any comments about this post? I am [@dasdom](https://alpha.app.net/dasdom).