Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Overloaded operator ends up with three arguments. (as documented)

by Anonymous Monk
on Mar 31, 2013 at 07:13 UTC ( #1026339=note: print w/ replies, xml ) Need Help??


in reply to Overloaded operator ends up with three arguments - SOLVED

Your mistake is here  use overload '+' => \&add_latency,

add_latency is not written to cooperate with overload

As overload examples  my ($self, $other, $swap) = @_;

To explain, + is a binop, binary operator, it takes two arguments ... this arglist is slightly clearer

my( $self_operand_overloaded, $other_operand, $other_operand_was_on_the_left_side ) = @_;

$other_operand can be undef

$other_operand_was_on_the_left_side is a boolean, not an object

overload explains in detail


Comment on Re: Overloaded operator ends up with three arguments. (as documented)
Select or Download Code
Re^2: Overloaded operator ends up with three arguments. (as documented)
by gnosti (Friar) on Mar 31, 2013 at 07:24 UTC
    Thanks for clarifying this.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026339]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2015-07-04 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls