Question mark and colon in statement. What does it mean?

后端 未结 7 1315
南方客
南方客 2020-11-27 14:03

What do the question mark (?) and colon (:) mean?

((OperationURL[1] == "GET") ? GetRequestSignature() : "")


        
相关标签:
7条回答
  • 2020-11-27 14:52

    It is the ternary conditional operator.

    If the condition in the parenthesis before the ? is true, it returns the value to the left of the :, otherwise the value to the right.

    0 讨论(0)
提交回复
热议问题