in reply to Re^3: Anonymous Hash in Constructor
in thread Anonymous Hash in Constructor
Ah, but using strict and warnings demonstrates that nothing in the example is considered bizarro stuff that Perl will complain about.
Yes, indeed. Adding even more stuff to the example could introduce many new invaluable lessons. A complete, well-written Perl application could serve as a primer in good object-oriented programming. No doubt. But my point here was simply that I learned a little something by going a bit reduction-crazy. Noise reduction as pedagogical aid.
Disregarding the original topic of this thread entirely, I learned more still by playing with this…
{ package Class; sub new { bless {} } # sub new { bless [] } # sub new { bless \$scalar } # sub new { bless \&sub } sub Method { print "This is a method happening.\n" } } $object = Class->new; $object->Method;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Anonymous Hash in Constructor
by tobyink (Canon) on Oct 19, 2012 at 23:09 UTC | |
by Jim (Curate) on Oct 19, 2012 at 23:42 UTC |