Swift Ismemberof

[Solved] Swift Ismemberof | Swift - Code Explorer | yomemimo.com
Question : swift isMemberOf

Answered by : rens-wijnmalen

class Animal {}
class Dog : Animal {}
class Cat : Animal {}
let c = Cat()
c is Dog // false
c is Cat // true
c is Animal // true
// In Swift => 3:
type(of: c) == Cat.self // true
type(of: c) == Animal.self // false
// In Swift 2:
c.dynamicType == Cat.self // true
c.dynamicType == Animal.self // false

Source : https://stackoverflow.com/questions/39347888/ismemberofclass-in-swift | Last Update : Tue, 15 Feb 22

Answers related to swift ismemberof

Code Explorer Popular Question For Swift