Last active
October 30, 2015 16:00
-
-
Save floriankrueger/b46505916e46a0f360fe to your computer and use it in GitHub Desktop.
specialized subclass of generic superclass
This file contains 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 | |
struct Something {} | |
class Base<T> { | |
let something: T | |
init(something: T) { | |
self.something = something | |
} | |
} | |
class Sub: Base<Something> { | |
// whatever 'Sub' does | |
} | |
let instance = Sub(something: Something()) // 'Sub' cannot be constructed because it has no accessible initializers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
struct Something {}
class Base {
let something: T
}
class Sub: Base {
override init(something: Something) {
super.init(something: something)
}
// whatever 'Sub' does
}
let instance = Sub(something: Something())