Skip to content

Instantly share code, notes, and snippets.

@mateuszszklarek
Created February 1, 2019 18:02
Show Gist options
  • Save mateuszszklarek/0a68a49710c145699a3b456b1887a9b2 to your computer and use it in GitHub Desktop.
Save mateuszszklarek/0a68a49710c145699a3b456b1887a9b2 to your computer and use it in GitHub Desktop.
func value() -> Any {
return 1
}
func optionalValue() -> Any? {
return 2
}
let x = value() as? Int
let y = optionalValue() as? Int
// as? In both cases create one level of nesting
print("Type of x: \(type(of: x))\nType of y: \(type(of: y))")
// Type of x: Optional<Int>
// Type of y: Optional<Int>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment