Comma usage in swift -


@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 tutorial learn swift. yesterday found part of code can not find way understand means thatcomma means. can u pls explain me?

the comma used combine multiple optional bindings 1 statement avoid unnecessary nesting.

from swift 1.2,the if let construct can unwrap multiple optionals @ once, include intervening boolean conditions. lets 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 , above support swift1.2.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -