I have a class X
with a subclass Y
. X
has a method calculate()
that I'd like to override in Y
with some additional behaviour, an if
statement that, if it fails, call X.calculate()
. In Python this would be accomplished with:
class X(object):
def calculate(self, my_arg):
return "Hello!"
class Y(X):
def calculate(self, my_arg):
if type(my_arg) is int and my_arg > 5:
return "Goodbye!"
return super(Y, self).calculate(my_arg)
How can I do this in Perl using the Moo
module?