Skip to content

Instantly share code, notes, and snippets.

@Pretz
Created October 24, 2014 21:59
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 Pretz/51da0a55fbbb37ff67a8 to your computer and use it in GitHub Desktop.
Save Pretz/51da0a55fbbb37ff67a8 to your computer and use it in GitHub Desktop.
Best way to initialize a `let` variable using a case statement?
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