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

后端 未结 7 1471
南方客
南方客 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.

提交回复
热议问题