summaryrefslogtreecommitdiffhomepage
path: root/vala.html.markdown
diff options
context:
space:
mode:
authorMilo Gilad <milogaccnts@gmail.com>2017-08-26 10:46:54 -0400
committerMilo Gilad <milogaccnts@gmail.com>2017-08-26 10:46:54 -0400
commit1b780b2d46bfad3084df5e454d5b5ca81601595a (patch)
tree298aeb2c7e38e658334d61b2c1aafdb1e0765176 /vala.html.markdown
parent41e5f956e1c3b351c85466d00c9f89d05ca7a84d (diff)
Getting type info dynamically
Diffstat (limited to 'vala.html.markdown')
-rwxr-xr-xvala.html.markdown11
1 files changed, 10 insertions, 1 deletions
diff --git a/vala.html.markdown b/vala.html.markdown
index c329447d..51cb8dc0 100755
--- a/vala.html.markdown
+++ b/vala.html.markdown
@@ -359,7 +359,7 @@ public abstract class OperatingSystem : GLib.Object {
public abstract void use_computer();
}
-public class Ubuntu : OperatingSystem {
+public class Linux : OperatingSystem {
public override void use_computer() { // Abstract methods must be overridden
stdout.printf("Beep boop\n");
}
@@ -400,6 +400,15 @@ interface Laptop { // May only contain abstracts or virtuals
public interface CellPhone : Collection, GLib.Object {}
+// You can get the type info of a class at runtime dynamically.
+
+bool type_info = object is TypeName; // uses "is" to get a bool
+
+Type type_info2 = object.get_type();
+var type_name = type_info2.name();
+
+Type type_info3 = typeof(Linux);
+Linux type_demo = (Linux) Object.new(type_info3);
```
* More Vala documentation can be found [here](https://valadoc.org/).