Skip to content

Instantly share code, notes, and snippets.

@dudarenko-io
Created September 5, 2017 09:51
Show Gist options
  • Save dudarenko-io/0144bfc68c7dae7a52b4165b2760de5d to your computer and use it in GitHub Desktop.
Save dudarenko-io/0144bfc68c7dae7a52b4165b2760de5d to your computer and use it in GitHub Desktop.
class A {}
class B: A {}
class C: A {}
extension A: CustomStringConvertible {
var description: String {
return "type of: \(type(of: self))"
}
}
let one = B()
let two = B()
print(type(of: one) == type(of: two)) // true
let p: A = two
switch p {
case let some as B:
print("B \(some)")
case is C:
print("C")
default:
print("don`t know")
}
// B type of: B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment