Ternary operator in PowerShell

后端 未结 13 2097
忘掉有多难
忘掉有多难 2020-11-28 03:56

From what I know, PowerShell doesn\'t seem to have a built-in expression for the so-called ternary operator.

For example, in the C language, which supports the terna

13条回答
  •  日久生厌
    2020-11-28 04:26

    Powershell 7 has it. https://toastit.dev/2019/09/25/ternary-operator-powershell-7/

    PS C:\Users\js> 0 ? 'yes' : 'no'
    no
    PS C:\Users\js> 1 ? 'yes' : 'no'
    yes
    

提交回复
热议问题