Created
October 24, 2014 21:59
-
-
Save Pretz/51da0a55fbbb37ff67a8 to your computer and use it in GitHub Desktop.
Best way to initialize a `let` variable using a case statement?
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
let inView: UIView = { | |
switch display { | |
case .InWindow: | |
return self.view.window! | |
case .AboveKeyboard: | |
return UIApplication.sharedApplication().windows[1] as UIView | |
default: | |
return self.view | |
} | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment