@IBAction func selectedGame(segue:UIStoryboardSegue) {
if let gamePickerViewController = segue.sourceViewController as? GamePickerViewController,
selectedGame = gamePickerViewController.selectedGame {
detailLabel.text = selectedGame
game = selectedGame
}
}
Hi all, i'm following a tutorial to learn something about swift. Yesterday I found this part of code but I can not find a way to understand what it means thatcomma means. Can u pls explain me?
The comma is used to combine multiple optional bindings into one statement to avoid unnecessary nesting.
From Swift 1.2,The if let construct can now unwrap multiple optionals at once, as well as include intervening boolean conditions. This lets you express conditional control flow without unnecessary nesting.More details
For example:
var foo: Int!
var bar: String!
// Swift 1.2
if let foo = foo,bar = bar {
// foo & bar have values.
} else {
}
// before Swift 1.2
if let foo = foo {
// nesting
if let bar = bar {
// foo & bar have value.
}
}
Xcode6.3 and above support Swift1.2.
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