0

I have this function:

void TakeHit(ref Player player){
    //...
}

And I have 2 Players called red and blue. Suppose there is a boolean isRed that says if the Player that is going to take the hit is red (true) or blue (false):

bool isRed = //...
TakeHit( /* what do I write here in a ternary operator??? */ );

I tried some syntaxes and this one seemed to compile

TakeHit(ref isRed ? ref red : ref blue);

although I didn't test since it looks super wierd and I'm asking just out of curiosity since a simple if can replace the ternary operator option.

Daniel
  • 7,357
  • 7
  • 32
  • 84

0 Answers0