user2809062
user2809062

Reputation: 11

AS3 to Java (boolean ? int:int)

var max:int = (splitH ? height : width) - MIN_LEAF_SIZE;

What would this look like in java? I don't know what the as3 code is doing exactly... Mainly the (splitH ? height : width) is tripping me up.

Upvotes: 1

Views: 66

Answers (2)

Johan Lindkvist
Johan Lindkvist

Reputation: 1784

It is as SLaks says. If you would translate conditional operator line to if and else it would look something like this:

var max:int = 0;
if(splitH)
{
    max = height - MIN_LEAF_SIZE;
}
else
{
    max = width - MIN_LEAF_SIZE;
}

Upvotes: 0

SLaks
SLaks

Reputation: 887449

That's a conditional operator.

Java has the exact same operator.

Upvotes: 2

Related Questions