Created
February 9, 2015 19:52
-
-
Save narfdotpl/3f52f720d3c9f311528a to your computer and use it in GitHub Desktop.
if-let-with-multiple-optionals-is-lazy.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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