Created
February 27, 2018 12:42
-
-
Save TerryCK/d1607985d204d78eee5dfd2a2134bf4a to your computer and use it in GitHub Desktop.
class inheritance enum
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
import Foundation | |
class ClassA { | |
private lazy var cellType = CellType.footer | |
init(_ x: Int) { | |
self.cellType = .footer | |
print("ClassA", self.cellType) | |
type(of: self.cellType) | |
} | |
init() { | |
print("class init") | |
} | |
} | |
extension ClassA { | |
enum CellType { | |
case header, body, footer | |
} | |
} | |
class ClassB: ClassA { | |
private lazy var cellType = CellType.none | |
override init() { | |
super.init() | |
self.cellType = .none | |
print("ClassB", self.cellType) | |
type(of: self.cellType) | |
} | |
} | |
extension ClassB { | |
private enum CellType { | |
case header, body, footer, none | |
init() { | |
self = .none | |
} | |
} | |
} | |
// no complie time error and warning :) | |
let classA = ClassA(1) | |
let classB = ClassB() | |
let x = classA | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment