Reducing the number of brackets in Swift

后端 未结 7 1886
离开以前
离开以前 2021-02-01 19:53

Does anyone know if there is a way to use some kind shorthand in swift? more specifically, leaving out the braces in things like IF statements... eg

if num == 0
         


        
7条回答
  •  长发绾君心
    2021-02-01 20:01

    You could use a shorthand if statement like you would in objective-c:

    num1 < num2 ? DO SOMETHING IF TRUE : DO SOMETHING IF FALSE
    

提交回复
热议问题