Sign up for FlowVella
Sign up with FacebookAlready have an account? Sign in now
By registering you are agreeing to our
Terms of Service
Loading Flow
Protocols are analogous to Java Interfaces
Classes can inherit from one parent, implement multiple protocols
Classes and
Protocols
protocol Exercising {
var heartRateIncrement : Int { get set }
func describe() -> String
}
class Walk : Exercising {
var heartRateIncrement : Int = 10
func describe() -> String { return "walking" }
}
class Jog : Exercising {
var heartRateIncrement : Int = 20
func describe() -> String { return "jogging at a moderate pace" }
}
class Person {
var heartRateResting : Int = 70
var heartRateTarget : Int = 140
var heartRate : Int = 70
}
https://gist.github.com/mthouser/4f8721f5fb89f5abb28f