in reply to Operation `bool': no method found, argument in overloaded package Vector2D at

You've going to kick yourself on this one.

while(pop(@p)) uses your Vector2D in a boolean context, so it's trying to find a "bool" method to find the boolean value of a Vector2D (IE if it is true or not). If you read the "MAGIC AUTOGENERATION" section of the overload manpage, you'll see that "bool" isn't mentioned there, meaning it can't be autogenerated. (Which makes sense -- all references are natively (or is that nievely?) true.)

Add a "bool" => \&bool line to your "use overload". (And write the coorosponding method, of course.)

TACCTGTTTGAGTGTAACAATCATTCGCTCGGTGTATCCATCTTTG ACACAATGAATCTTTGACTCGAACAATCGTTCGGTCGCTCCGACGC
  • Comment on Re: Operation `bool': no method found, argument in overloaded package Vector2D at

Replies are listed 'Best First'.
Re: Re: Operation `bool': no method found, argument in overloaded package Vector2D at
by rbc (Curate) on Jan 24, 2002 at 08:37 UTC
    I see I need to do this in my Vector2D package ...
    use overload "-" => \&minus, "+" => \&plus, "*" => \&mult, "bool" => \&bool; sub bool { my $object = shift; return !undef($obj); }
    ... or I am more clueless than you thought :)

    Thanks!
        What was I thinking ...

        I meant ...
        sub bool { return defined (shift); }
        ... I think? Right?

        Why don't I just run it and find out!
        Thanks again