I used to program in Objective-C all the time and I am new to Swift. This error Xcode gives me really confuse me.
func renderBufferAreaBAUp(yOffset: CGFloat, amount: CGFloat, ifLeft: Bool)
{
var topViewIndexForIndexAdjust = ifLeft?leftTopIndex:rightTopIndex
}
On this line I intended to use ternary. leftTopIndex and rightTopIndex are both Int type. However Xcode gives me those on this particular line,
Consecutive statements on a line must be separated by ';' Expected expression
Can anybody tell me what those mean? Thanks.
Swift error messages are frequently cryptic and not helpful. Your real problem is that Swift needs some space around the ? and :.
var topViewIndexForIndexAdjust = ifLeft ? leftTopIndex : rightTopIndex
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With