Closed Geod24 closed 6 years ago
You misplaced the modifier. This works:
@@ -8,16 +8,16 @@ class Cat : Animal {}
class Dolphin : Animal {}
// open method with single argument <=> virtual function "from outside"
-string kick(virtual!Animal);
+string kick(virtual!(const Animal));
@method // implement 'kick' for dogs
-string _kick(Dog x) // note the underscore
+string _kick(const Dog x) // note the underscore
{
return "bark";
}
@method("kick") // use a different name for specialization
-string notGoodIdea(Pitbull x)
+string notGoodIdea(const Pitbull x)
{
return next!kick(x) ~ " and bite"; // aka call 'super'
}
According to this example,
const
andimmutable
are casted away. I'd expect that a nonconst
implementation would error out. Likewise, I'd expect animmutable
implementation of aconst
function to error. Aconst
implementation of animmutable
method should be fine though.