PDA

View Full Version : 3 way checker



charlie
May 16th, 2003, 05:10 AM
I know this can be done with if(), but is there not an operation which can do this?
I am checking between 2 variables and whichever is smallest is assigned to a third.

if (a<=b) {
c = a
} else if (b<a) {
c = b
}

WelshDragoon
May 16th, 2003, 01:44 PM
I cant think of a much shorter way, but you could cut out about 5 letters by doing ths:

if (a<=b) {
c = a
} else {
c = b
}