-2

I should probably know that but I'm not sure what this line of code is doing:

int iEnd=i==grid.length - 1 ? 0:1;
Dawood ibn Kareem
  • 77,785
  • 15
  • 98
  • 110
bfg
  • 13
  • 5

1 Answers1

0

it will set iEnd to 0 if i equals grind.length -1 otherwise it will set iEnd to 1

the operator is called Ternary Operator and is a short hand for a Conditional Operator and you can read more about it here: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html

Jocke
  • 2,189
  • 1
  • 16
  • 24