Skip to content

Instantly share code, notes, and snippets.

@mildocjr
Created August 11, 2018 01:51
Show Gist options
  • Save mildocjr/237787d3a26d6c11e2143f3435d2b8e1 to your computer and use it in GitHub Desktop.
Save mildocjr/237787d3a26d6c11e2143f3435d2b8e1 to your computer and use it in GitHub Desktop.
type-cast-4
var integerValue = 42
var stringValue = String(describing: 42)
var doubleValue = integerValue as! Double
var floatValue = Int(stringValue) as? Float
var array: [String] = ["eggs", "bacon", "ham", "cheese"]
let arrayCount = Double(array.count as? String)
var numArray: [Int] = [1, 2, 3, 4, 5]
var anotherDouble = numArray[3] as? Double
var isSunny = true
var sunnyString = String(describing: isSunny)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment