Try using it like this :
x = isCompleted ? intValue(if true) : intValue(if false);
Since you have declared x
as int
, you will have to provide the values in int
irrespective of the condition evaluated. Any other type value you use wont work here. Hence the false
that you wrote is wrong. You might want to provide an int
value there.
Incase if you want to perform some code logic based on bool conditions, you might want to use if...else
here as that will help you do more than just assigning some values to variables.
Hope this helps.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…