Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Perl OOP

by SpanishInquisition (Pilgrim)
on Oct 11, 2004 at 20:02 UTC ( [id://398275]=note: print w/replies, xml ) Need Help??


in reply to Perl OOP

A few basic things to remember.

(1) In Perl, bless is something sort of magical. New is just a function you create. So it could just be named "Defroobniculate". "new" is preferred of course, but whatever it does is essentially legal. Your packages technically don't have to return an object at all.

(2) Creating multiple blessed objects inside of new is perfectly legal, but I want to ask "why" here, as to why you are returning more than one. If you are constructing an object tree, for instance, usually you would expect the return of the root node. What you are doing is totally legal and valid, I'm just curious... I haven't needed a "new_dog_and_cat" function before -- though perhaps I could see a return of a list of objects (or a hash of objects) being useful. (I just want to find an example where that would be the case)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found