1

Maybe a stupid question for you, but I found a site where this source was given with no further info. I searched with google but I got no useful suggestions.

I want to know what this line actually does. Give me a link or the name of this function? so I can look it up myself.

Thank you :)

y += (x<= uz ? 1.0 : 0.0) * radius;

I know what += and * do, but the rest is a huge questionmark

Pris0n
  • 285
  • 5
  • 20

2 Answers2

3

It is a ternary operator.

Conditional (Ternary) Operator (?:)

Returns one of two expressions depending on a condition.

test ? expressionIfTrue : expressionIfFalse

With your code it is the same as:

if (x<uz) {
  y += radius;
} else {
  y += 0;
} 
Umur Kontacı
  • 35,099
  • 7
  • 69
  • 94
epascarello
  • 185,306
  • 18
  • 175
  • 214
2

That is a ternary operator. Basically this translates to:

var y;
// ...

if( x <= uz ) {
  y += 1.0 * radius;
} else {
  y += 0.0 * radius;
}
Sirko
  • 65,767
  • 19
  • 135
  • 167