|
@@ -144,25 +144,25 @@ There are many cases where nested classes can lead to more readable and maintain
|
|
### Inheritance
|
|
### Inheritance
|
|
Single class inheritance is supported in Gravity.
|
|
Single class inheritance is supported in Gravity.
|
|
```swift
|
|
```swift
|
|
-class Bird {
|
|
|
|
- func talk() {
|
|
|
|
- System.print("Cheep")
|
|
|
|
|
|
+ class Bird {
|
|
|
|
+ func talk() {
|
|
|
|
+ System.print("Cheep")
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
|
|
-class Owl : Bird {
|
|
|
|
- func talk() {
|
|
|
|
- System.print("Hoot")
|
|
|
|
|
|
+ class Owl : Bird {
|
|
|
|
+ func talk() {
|
|
|
|
+ System.print("Hoot")
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
|
|
-func main() {
|
|
|
|
- var bird = Bird()
|
|
|
|
- bird.talk() // Output: Cheep
|
|
|
|
|
|
+ func main() {
|
|
|
|
+ var bird = Bird()
|
|
|
|
+ bird.talk() // Output: Cheep
|
|
|
|
|
|
- var owl = Owl()
|
|
|
|
- owl.talk() // Output: Hoot
|
|
|
|
-}
|
|
|
|
|
|
+ var owl = Owl()
|
|
|
|
+ owl.talk() // Output: Hoot
|
|
|
|
+ }
|
|
```
|
|
```
|
|
|
|
|
|
### Access specifiers
|
|
### Access specifiers
|