If I have a class:
class Spaceship<FuelType> {
function prepareForLiftoff() throws {
}
}
It was originally supposed that I could override prepareForLiftoffwithout subclassing by adding the extension:
extension Spaceship where FuelType: CollectionType {
func prepareForLiftoff() throws {}
}
This code does not compile, but the error says about the invalid redeclarationfunction, which makes sense.
My question is: Is there a way to override a function of a particular class? In other words, I can replace functionality under certain conditions, such as the example above, where FuelType: CollectionType. If not, is there another way or way to achieve this behavior (perhaps declaring a different protocol, idk)
Now that I think about it more, I have to say that this is impossible, because in order to stop someone from overriding any standard library functions?