Example

Inheritance using override

Dog overrides Speak. Runtime polymorphism does the rest. Woof.

Save this as a .alana file, then alana filename.alana. And start coding cute.

define class Animal;

public:
define func Speak() returning str;
    return "...";
end;

end;


define class Dog extends Animal;

public:
define override func Speak() returning str;
    return "Woof!";
end;

end;


define Dog dog is newobj Dog();

showln call dog.Speak();