Skip to content

Instantly share code, notes, and snippets.

@jplazcano87
Created February 11, 2016 14:01
Show Gist options
  • Save jplazcano87/32ee4cc419a5ad14f0f1 to your computer and use it in GitHub Desktop.
Save jplazcano87/32ee4cc419a5ad14f0f1 to your computer and use it in GitHub Desktop.
Ternanry operator in swift 2
var a:Int?
let b = 2
var output:Int?
//a is nil here
output = a ?? b
print("Value of Output is \(output!)")
//a is assigned value of b
a = 1 //Assigning Value to a
output = a ?? b
print("Value of Output is \(output!)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment