Swift三元语法错误

Big*_*man 2 ternary-operator swift

我曾经一直在Objective-C中编程,而且我是Swift的新手.这个错误Xcode让我真的很困惑.

func renderBufferAreaBAUp(yOffset: CGFloat, amount: CGFloat, ifLeft: Bool)
{     
        var topViewIndexForIndexAdjust = ifLeft?leftTopIndex:rightTopIndex
}
Run Code Online (Sandbox Code Playgroud)

在这一行,我打算使用三元.leftTopIndex和rightTopIndex都是Int类型.然而Xcode给了我这些特定线上的那些,

一行上的连续陈述必须用';'分隔 期待的表达

谁能告诉我这些意味着什么?谢谢.

vac*_*ama 11

Swift错误消息经常是神秘的,没有帮助.你真正的问题是,斯威夫特需要周围的一些空间?:.

var topViewIndexForIndexAdjust = ifLeft ? leftTopIndex : rightTopIndex
Run Code Online (Sandbox Code Playgroud)