Created
September 5, 2017 09:51
-
-
Save dudarenko-io/0144bfc68c7dae7a52b4165b2760de5d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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