A fine way of both shortening and simplifying is if you use the question mark. It's called a ternary operator. With this, you can do conditional assignments on one line.
Consider the following example (taken from Bresenhams line algorithm) :
ystep = 1;
ystep = -1;
The code above could be shortened to one line:
int ystep = y0 < y1 ? 1 : -1;
Click anywhere to cancel