can someone explain this sentence to me please
int m1 = a < b ? a : b;
PEPE
Nivel 2
expanatoin of ths sentence
En discusión
Comentarios (3)
- Populares
- Nuevas
- Antiguas
Debes iniciar sesión para dejar un comentario
Anonymous #11410931
19 octubre 2023, 10:12
Hello!
It's something similar to : if (int m1) = (a<b), then the result is (a), if not, the result is (b).
Or, if the sentence (int m1=a<b) is TRUE, then the result is (a). If the sentence is FALSE, then the result is (b)
The ? sign is to determine if the sentence is TRUE or FALSE.
Have a nice day,
Matildas
+1
Thomas
30 noviembre 2022, 12:49
That's called ternary operator (google) and means smth like that:
It's an assignment operator. Means you need to assign values. It doesn't work for pure method calls.
+1
PEPE
1 diciembre 2022, 15:49
thank you
+1