I want to create structure with method inside it, with a switch statement that switches on the instance's property, and appends self
to the proper array.
Trying this, but it's wrong:
struct Workout {
enum Stroke {
case freestyle, butterfly
}
var distance : Double
var time: Double
var stroke: Stroke
var freestyleArray : [Workout] = []
var butterflyArray : [Workout] = []
mutating func saveToArray () {
switch stroke {
case .freestyle : freestyleArray.append(self)
case .butterfly : butterflyArray.append(self)
}
}
}