summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMilo Gilad <milogaccnts@gmail.com>2017-08-26 10:58:00 -0400
committerMilo Gilad <milogaccnts@gmail.com>2017-08-26 10:58:00 -0400
commita0095c2884580f5a479c677f08470c5aee4a7555 (patch)
tree7b8da6da4df67899e363d5ebd56446a42097daf7
parent1b780b2d46bfad3084df5e454d5b5ca81601595a (diff)
Added section on generics
-rwxr-xr-xvala.html.markdown15
1 files changed, 15 insertions, 0 deletions
diff --git a/vala.html.markdown b/vala.html.markdown
index 51cb8dc0..350d3d88 100755
--- a/vala.html.markdown
+++ b/vala.html.markdown
@@ -410,6 +410,21 @@ var type_name = type_info2.name();
Type type_info3 = typeof(Linux);
Linux type_demo = (Linux) Object.new(type_info3);
+// Generics
+
+class Computer<OperatingSystem> : GLib.Object {
+ private OperatingSystem os;
+
+ public void install_os(OperatingSystem os) {
+ this.os = os;
+ }
+ public OperatingSystem retrieve_os() {
+ return this.os;
+ }
+}
+
+var new_computer = new Computer<Linux>();
+
```
* More Vala documentation can be found [here](https://valadoc.org/).
* Read about building GUIs with GTK+ and Vala [here](http://archive.is/7C7bw).