You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
protocolBird{varname:String{get}varcanFly:Bool{get}}protocolFlyable{varairspeedVelocity:Double{get}}structFlappyBird:Bird,Flyable{letname:StringletflappyAmplitude:DoubleletflappyFrequency:DoubleletcanFly=truevarairspeedVelocity:Double{3* flappyFrequency * flappyAmplitude
}}structPenguin:Bird{letname:StringletcanFly=false}structSwiftBird:Bird,Flyable{varname:String{"Swift \(version)"}letcanFly=trueletversion:DoubleprivatevarspeedFactor=1000.0init(version:Double){self.version = version
}
// Swift is FASTER with each version!
varairspeedVelocity:Double{
version * speedFactor
}}
insert the following just below the Bird protocol definition:
extension Bird {
// Flyable birds can fly!
var canFly: Bool { self is Flyable }
}
Now delete the let canFly = ... from FlappyBird, Penguin and SwiftBird.
structFlappyBird:Bird,Flyable{letname:StringletflappyAmplitude:DoubleletflappyFrequency:DoublevarairspeedVelocity:Double{3* flappyFrequency * flappyAmplitude
}}structPenguin:Bird{letname:String}structSwiftBird:Bird,Flyable{varname:String{"Swift \(version)"}letversion:DoubleprivatevarspeedFactor=1000.0init(version:Double){self.version = version
}
The text was updated successfully, but these errors were encountered:
insert the following just below the Bird protocol definition:
Now delete the let canFly = ... from FlappyBird, Penguin and SwiftBird.
The text was updated successfully, but these errors were encountered: