sub foo { my $self=shift; if (@_==1) { // do something with single arg } elsif (@_==2) { // do something with two args } }
Point is that in a language like perl we can a) simulate the behaviour of java, b) we can provide behaviour that java plain and simple cant provide.
Incidentally what do we do with
foo(@bar);
Which version of foo should be called? Should the langauge simulate the if that i put inside the sub above? If so what do you do when you have a situation that doesnt make sense? For instance if @bar contains 3 vars. What should it do? Call the var version and ignore the third? Die?
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
In reply to Re: Re: perl6 & OO
by demerphq
in thread perl6 & OO
by chance
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |