Well, that does what you think it does, probably. If the object you're trying to determine the truth of is defined, then this will return a true value, and the Vector2D will thus be considered true.

However, consider for a moment under what circumstances this will return false.

defined() returns false only if it's argument is undef. However, undef isn't-a Vector2D, so your bool() function will never get called on undef.

You method, in other words, is equivilent to sub bool {return 1;} (golfers note: in all of these examples, the return and semicolon are optional. I find that confusing, so don't use it.).

Think about what the semantics of truth for a Vector2D are, then write your function.

(BTW, I don't mean for this to sound snippy or anything, I'm just in a kind of off mood.)

TACCTGTTTGAGTGTAACAATCATTCGCTCGGTGTATCCATCTTTG ACACAATGAATCTTTGACTCGAACAATCGTTCGGTCGCTCCGACGC

In reply to Re: Re: Re: Re: Re: Operation `bool': no method found, argument in overloaded package Vector2D at by theorbtwo
in thread Operation `bool': no method found, argument in overloaded package Vector2D at by rbc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.