diff options
author | Milo Gilad <milogaccnts@gmail.com> | 2017-08-26 10:58:00 -0400 |
---|---|---|
committer | Milo Gilad <milogaccnts@gmail.com> | 2017-08-26 10:58:00 -0400 |
commit | a0095c2884580f5a479c677f08470c5aee4a7555 (patch) | |
tree | 7b8da6da4df67899e363d5ebd56446a42097daf7 | |
parent | 1b780b2d46bfad3084df5e454d5b5ca81601595a (diff) |
Added section on generics
-rwxr-xr-x | vala.html.markdown | 15 |
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). |