Search Unity

Question Question mark and colon in float declaration c#

Discussion in 'Editor & General Support' started by etekmen13, Mar 28, 2023.

  1. etekmen13

    etekmen13

    Joined:
    Dec 2, 2017
    Posts:
    3
    What does the following code mean?
    I've seen that question mark indicates nullable type, but I don't think thats the case here.

    float f = UnityEngine.Random.value > 0.5f ? -1f : 1f;
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,933