Created
February 1, 2019 18:02
-
-
Save mateuszszklarek/0a68a49710c145699a3b456b1887a9b2 to your computer and use it in GitHub Desktop.
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
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