Posts

Showing posts with the label final classes

Treehouse Intermediate Course Part 6 (Type Methods and Final Classes)

Here we go! Just a little bit more today - which is best - little and often! Last time it was semantics for value and reference types. I'm starting with Type Methods.... Type Methods Before we used the keyword 'static' for properties, computed ones I believe. struct Point {     let x: Double     let y: Double } struct Map {     static let origin = Point (x: 0 , y: 0 )          static func distance(to point: Point ) -> Double {         let horizontalDistance = origin . x - point. x         let verticalDistance = origin . y - point. y                  func square( _ value: Double ) -> Double {             return value * value         }                  let horizontalDistanceSquare = square (horiz...