Skip to content

Instantly share code, notes, and snippets.

@narfdotpl
Created February 9, 2015 19:52
Show Gist options
  • Save narfdotpl/3f52f720d3c9f311528a to your computer and use it in GitHub Desktop.
Save narfdotpl/3f52f720d3c9f311528a to your computer and use it in GitHub Desktop.
if-let-with-multiple-optionals-is-lazy.swift
// Of course, `if let` with multiple optionals is lazy.
//
// Tested on 2015-02-09 in Xcode 6.3 Beta 1, Swift 1.2.
func foo() -> Int? {
println("foo")
return 0
}
func bar() -> Int? {
println("bar")
return nil
}
func baz() -> Int? {
println("baz")
return 0
}
if let a = foo(), b = bar(), c = baz() {
println("boom")
}
// prints:
//
// foo
// bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment