2
0
Эх сурвалжийг харах

Added documentation around single inheritance

Found that documentation surrounding class inheritance was missing. So, here you go!
Rob Loach 5 жил өмнө
parent
commit
fab486c4f0
1 өөрчлөгдсөн 24 нэмэгдсэн , 0 устгасан
  1. 24 0
      docs/class.md

+ 24 - 0
docs/class.md

@@ -141,5 +141,29 @@ There are many cases where nested classes can lead to more readable and maintain
 	}
 	}
 ```
 ```
 
 
+### Inheritance
+Single class inheritance is supported in Gravity.
+```swift
+class Bird {
+	func talk() {
+		System.print("Cheep")
+	}
+}
+
+class Owl : Bird {
+	func talk() {
+		System.print("Hoot")
+	}
+}
+
+func main() {
+	var bird = Bird()
+	bird.talk() // Output: Cheep
+
+	var owl = Owl()
+	owl.talk() // Output: Hoot
+}
+```
+
 ### Access specifiers
 ### Access specifiers
 The public and private keywords can be used to restrict access to specific parts of code.
 The public and private keywords can be used to restrict access to specific parts of code.