所以我有一個名爲push
的方法。在這個方法裏面,我調用perl的內建函數push
。現在我有另一個名爲unshift
的方法,並且在這個方法裏面,我再次調用perl的內建push
函數。與perl內部名稱相同的程序包方法
1 package Deque;
2
3 ...
4 sub push {
5 my ($self, $node) = @_;
6 push @{ $self->{nodes} } => $node;
7 ...
8 }
9
10 sub unshift {
11 my ($self, $node) = @_;
12 push @{ $self->{nodes} } => $node;
13 ...
14 }
該程序運行,但我得到這個警告Ambiguous call resolved as CORE::push() ... line 12
。
因此,我將第12行更改爲CORE::push @{ $self->{nodes} } => $node
,並且警告消失。
perl怎麼沒有提醒我關於第6行? 有沒有更好的方法來擺脫警告?我無法更改方法名稱。
+1尼斯抓:) – Miller