关于perl中的构造函数
sub new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $self = { @_ }; # Remaining args become attributes
bless($self, $class); # Bestow objecthood
return $self;
}
其中第一行和第二行是什么意思?
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $self = { @_ }; # Remaining args become attributes
bless($self, $class); # Bestow objecthood
return $self;
}
其中第一行和第二行是什么意思?
作者: sf_lsy 发布时间: 2010-11-26
认真阅读下Intermediate Perl(假设你已经读过Learning Perl)。
作者: iambic 发布时间: 2010-11-26
比如我在$self->{query_object} = new Query( "abc", "123" );
是不是 在new里面,第一次shift操作的是类名,而不是"abc"?
是不是 在new里面,第一次shift操作的是类名,而不是"abc"?
作者: sf_lsy 发布时间: 2010-11-26