How do I use the conditional operator?

后端 未结 9 1049
忘了有多久
忘了有多久 2020-11-22 16:27

I\'ve always wondered how to write the \"A ? B : C\" syntax in a C++ compatible language.

I think it works something like: (Pseudo

9条回答
  •  一个人的身影
    2020-11-22 17:24

    IT IS QUITE SIMPLE IT'S BASIC SYNTAX IS: expression1?expression2:expression3;

    If expression 1 is hold true then expression 2 will hold otherwise expression 3 will hold.

    example:

    hey=24>2?24:34;

    here as condition is true value of 24 will be assigned to it. if it was false then 34 will be assigned to it

提交回复
热议问题