Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Re: OO Perl: calling a constructor within a class

by TheDamian (Priest)
on Sep 28, 2001 at 11:06 UTC ( #115329=note: print w/replies, xml ) Need Help??


in reply to Re: Re: OO Perl: calling a constructor within a class
in thread OO Perl: calling a constructor within a class

Careful with that ||=, Eugene!
Did you really want to prohibit a cereal number of zero?

That's why I generally avoid using ||= to specify defaults.
Unless I'm very sure my incoming data won't ever be 0, "0", or "".

Besides, there are ways to tell if she is a witch:

$name = '' unless defined $name; $rank = '' unless defined $rank; $c_num = '' unless defined $c_num;
or:
foreach ($name, $rank, $c_num) { defined or $_ = '' }
or the strange-but-lovely:
$_ = '' for grep !defined => ($name, $rank, $c_num);
or the tried and true:
$name = '' if weight($name) == weight($duck); $rank = '' if weight($rank) == weight($duck); $c_num = '' if weight($c_num) == weight($duck);

Err...

Oh, yes, I should also mention that next week, when Apocalypse III and Exegesis III appear, you'll find that Perl 6 is going to have a much nicer way to solve this problem.

Damian

Replies are listed 'Best First'.
Re: Re: Re: Re: OO Perl: calling a constructor within a class
by blakem (Monsignor) on Sep 28, 2001 at 11:20 UTC
    Perl 6 is going to have a much nicer way to solve this problem.

    I like the sound of that... last I heard there was some strong opposition to an ||= that tests for definedness rather than truthfulness. I've always been on the side of having such a construct, especially since ||= is so tempting for newbies to use, even *after* they've been told of the pitfalls.

    The only remaining question is what will the operator look like?

    -Blake

      The only remaining question is what will the operator look like?

      if (tell $you) { require kill 9 => $you }

      ;-)

      The only remaining question is what will the operator look like?

      I didn't tell you this, right, but you may find a clue here.

      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you don't talk about Perl club."

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2021-05-08 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (96 votes). Check out past polls.

    Notices?