不清楚了解?:用迅捷的语法

Jos*_*nor -7 syntax swift

我在return语句中无法理解这种语法.我不确定它是否是Swift 2.0中的新功能,但它是什么?和:意思是?这个问号是否可选,即使间隔?我很困惑,来自Objective-C背景.

private func doContainsUser(user: User) -> Bool {
    let isInverted = setOfDiff.contains(user)
    let wasInitiallyAdded = setOfCircleUsers.contains(user)

    //What does the ? and the : mean?
    return isInverted ? !wasInitiallyAdded : wasInitiallyAdded
}
Run Code Online (Sandbox Code Playgroud)

egf*_*nor 5

这是一个简短的if if else声明.

if isInverted {
   return !wasInitiallyAdded
}
else {
   return wasInitiallyAdded
}
Run Code Online (Sandbox Code Playgroud)