summaryrefslogtreecommitdiffhomepage
path: root/vala.html.markdown
diff options
context:
space:
mode:
authorMilo Gilad <milogaccnts@gmail.com>2017-08-26 10:34:16 -0400
committerMilo Gilad <milogaccnts@gmail.com>2017-08-26 10:34:16 -0400
commit41e5f956e1c3b351c85466d00c9f89d05ca7a84d (patch)
tree77d5859bf04e7c16d4dd96117e29fcac7e627cde /vala.html.markdown
parentce745f43ed3deef655b232cb095e3d446db716a5 (diff)
Began interface section
Diffstat (limited to 'vala.html.markdown')
-rwxr-xr-xvala.html.markdown17
1 files changed, 16 insertions, 1 deletions
diff --git a/vala.html.markdown b/vala.html.markdown
index 923b152e..c329447d 100755
--- a/vala.html.markdown
+++ b/vala.html.markdown
@@ -380,11 +380,26 @@ public class MyHD : HardDrive {
// Interfaces: classes can implement any number of these.
-interface Laptop { // May only contain abstract methods
+interface Laptop { // May only contain abstracts or virtuals
public abstract void turn_on();
public abstract void turn_off();
+
+ public abstract int cores; // Won't compile; fields cannot be abstract
+ public abstract int cores {get; set;} // Will compile
+
+ public virtual void keyboard() { // Virtuals are allowed (unlike Java/C#)
+ stdout.printf("Clickity-clack\n");
+ }
}
+// The ability to use virtuals in Vala means that multiple inheritance is
+// possible (albeit somewhat confined)
+
+// Interfaces cannot implement interfaces, but they may specify that certain
+// interfaces or classes must be also implemented (pre-requisites).
+
+public interface CellPhone : Collection, GLib.Object {}
+
```
* More Vala documentation can be found [here](https://valadoc.org/).