Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Anonymous Hash in Constructor

by jmlynesjr (Hermit)
on Oct 19, 2012 at 01:14 UTC ( #999838=note: print w/replies, xml ) Need Help??

in reply to Anonymous Hash in Constructor

Wouldn't an anonymous hash provide for/enforce encapsulation, a basic OOP concept?



Thanks for the explanation. As always, I have more reading to do! My thought was that naming the hash would create a symbol table entry that would allow direct access from the outside, not that you would want to or should do that.

Replies are listed 'Best First'.
Re^2: Anonymous Hash in Constructor
by chromatic (Archbishop) on Oct 19, 2012 at 05:01 UTC

      Which, of course, would not make sense to do.   The constructor’s purpose is to return a new unique instance of a blessed object as its return value.   So, the only “debate” here is whether, within the body of that constructor, the hash that is to be returned is specified anonymously or not.   And, it makes utterly no difference one way or the other to Perl.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999838]
[Discipulus]: each node has 2 descendants only: can i just compose hash keys usinng coords?
[karlgoethebier]: Discipulus: you shouldn't smoke turkish spices before noon
[Discipulus]: karl you says the same of my mom: in your place I'd been
[Discipulus]: preoccupied.. ;=)
Discipulus stopped with turkisk spices anyway.. but better hashes than arrays!
[oiskuu]: Discipulus, from the edge or from the top?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2018-03-19 10:57 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (239 votes). Check out past polls.