How do I use the conditional operator?

后端 未结 9 941
忘了有多久
忘了有多久 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:20

    I would say the ? is a short-cut. However, some "hard-core" programmers tend to say write it out the long way so in future cases, people can easily read and modify code.

    For example, if you write

    int a = b

    Some people claim that it's clearer to write:

    if(b

    Because in future cases, people can catch it. Of course, a simple b

提交回复
热议问题