Skip to content

Instantly share code, notes, and snippets.

@tarunon
Last active October 6, 2017 13:16
Show Gist options
  • Save tarunon/d49e51937a242c01c8d7bfd57ae0e64a to your computer and use it in GitHub Desktop.
Save tarunon/d49e51937a242c01c8d7bfd57ae0e64a to your computer and use it in GitHub Desktop.
[Int(1)] is [String] // false
[Int]() is [String] // true
[Int?.none] is [String] //false
[Int?.some(1)] is [String?] // false
[Int?.none] is [String?] // true
[Int(1)] as? [String] // nil
[Int]() as? [String] // []
[Int?.none] as? [String] // nil
[Int?.some(1)] as? [String?] // nil
[Int?.none] as? [String?] // [nil]
let a1 = [Int?.none] as? [Int??]
let a2 = [Int?.none] as [Int??]
switch a1!.first! {
case .none:
print("come here")
case .some(.none):
fatalError()
case .some(.some):
fatalError()
}
switch a2.first! {
case .none:
fatalError()
case .some(.none):
print("come here")
case .some(.some):
fatalError()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment