Class
- Can be used against
- Computed properties in Classes
- Methods in Classes
- Using this causes
- The Property/Method to become part of the Type instead of Instance.
class Apple {
class var price : Double { return 1.5 }
class func weight() -> Int { return 1 }
}
Final
- Can be used against
- Stored/Computed Properties in Classes
- Methods in Classes
- Classes
- Using this causes
- Prevention of further overriding of the Property/Method in a Subclass
- Prevention of Sub classing in the case of Classes
class Apple {
final var price : Double = 1.5
final func weight() -> Int { return 1 }
}
final class Orange {
var price : Double = 2.5
func weight() -> Int { return 2 }
}
Static
- Can be used against
- Stored/Computed Properties in Classes, Structures, Enumerations
- Methods in Classes, Structures, Enumerations
- Using this causes
- The Property/Method to become part of the Type instead of Instance (similar to Class keyword)
- Prevention of further overriding of the Property/Method (similar to Final keyword)
struct Mango {
static var price: Double = 3.5
static func weight() -> Int { return 3 }
}