在Perl 6中调用类中的私有方法
发布时间:2020-12-16 06:19:28 所属栏目:大数据 来源:网络整理
导读:我不能在Perl 6中的类中调用私有方法: class MyClass { method !my-private-method($var1) { # .... } method my-method() { my $my-var1 = !my-private-method(123); # not found (Undeclared routines) my $my-var1 = $!my-private-method(123); # not fo
我不能在Perl 6中的类中调用私有方法:
class MyClass { method !my-private-method($var1) { # .... } method my-method() { my $my-var1 = !my-private-method(123); # not found (Undeclared routines) my $my-var1 = $!my-private-method(123); # not found (Undeclared routines) my $my-var1 = $.my-private-method(123); # not found (Undeclared routines) my $my-var1 = my-private-method(123); # not found (Undeclared routines) 那么如何从my-method调用my-private-method呢? 解决方法
您必须在实例对象上调用private方法.
my $my-var1 = self!my-private-method(123); 应该管用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |