Skip to content

Instantly share code, notes, and snippets.

@mateuszszklarek
Created February 1, 2019 18:06
Show Gist options
  • Save mateuszszklarek/f82c9a8df678596fe8f625963d94b874 to your computer and use it in GitHub Desktop.
Save mateuszszklarek/f82c9a8df678596fe8f625963d94b874 to your computer and use it in GitHub Desktop.
class CustomObject {
func value() -> Int {
return 5
}
func optionalValue() -> Int? {
return nil
}
}
var optionalObject: CustomObject? = CustomObject()
let x = optionalObject?.value()
let y = optionalObject?.optionalValue()
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