From ce745f43ed3deef655b232cb095e3d446db716a5 Mon Sep 17 00:00:00 2001 From: Milo Gilad Date: Sat, 26 Aug 2017 09:09:15 -0400 Subject: Moved interface into its own section and clarified constructor overloading --- vala.html.markdown | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'vala.html.markdown') diff --git a/vala.html.markdown b/vala.html.markdown index 6e1a215f..923b152e 100755 --- a/vala.html.markdown +++ b/vala.html.markdown @@ -255,13 +255,8 @@ class Message : GLib.Object { // Class Message extends GLib's Object } -interface Laptop { // May only contain abstract methods - public abstract void turn_on(); - public abstract void turn_off(); -} - -// Since method overloading isn't possible, you can use named constructors -// to get the same functionality. +// Since method overloading isn't possible, you can't overload constructors. +// However, you can use named constructors to achieve the same functionality. public class Calculator : GLib.Object { @@ -383,6 +378,14 @@ public class MyHD : HardDrive { } } +// Interfaces: classes can implement any number of these. + +interface Laptop { // May only contain abstract methods + public abstract void turn_on(); + public abstract void turn_off(); +} + + ``` * More Vala documentation can be found [here](https://valadoc.org/). * Read about building GUIs with GTK+ and Vala [here](http://archive.is/7C7bw). -- cgit v1.2.3