Skip to content

Instantly share code, notes, and snippets.

@godrm
Created December 29, 2017 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save godrm/dff4fc073bbd713628823143b25b619d to your computer and use it in GitHub Desktop.
Save godrm/dff4fc073bbd713628823143b25b619d to your computer and use it in GitHub Desktop.
var x : Int? = 10
//arguments
func foo(arg : Int?) {
guard let arg = arg else {
return
}
print(arg)
}
foo(arg:x)
//global variable
guard let x = x else { throw NSError() }
print(x)
//local variable
func bar() {
let y : Int? = 100
guard let y = y else { return }
print(y)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment