Ternary in if condition | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Ternary in if condition

Is it possible to use ternary operator inside if conditions??

26th Aug 2018, 4:55 AM
Sri
5 Answers
+ 10
Yes.
26th Aug 2018, 4:57 AM
Harsh
Harsh - avatar
+ 8
Is there a specific code snippet leading you to believe that you cannot?
26th Aug 2018, 4:58 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
No I just came with the situtation where i needed ternary inside if.
26th Aug 2018, 5:00 AM
Sri
0
Yes
2nd Sep 2018, 5:16 PM
Vaibhav Gupta
0
No, it’s like c-condition if((c1 && c2) ? true : c3)
2nd Sep 2018, 5:46 PM
Sri