in reply to Re^3: Can I add methods to an existing object?
in thread Can I add methods to an existing object?

pileofrogs didn't specify that it needs to be done at run-time. It would be my preference to resolve such issues at compile-time unless there is some feature of the final product that required deferral of the sub declaration until run-time.

It is good to make the difference clear, I guess, just in case the difference really matters to someone looking for a way to add a class method from outside the package scope. That's not really the question that was asked, since pileofrogs asked about adding a method to an object. In many cases adding a method to the class is just as good as adding it to the object instance, so no harm done from that little difference. It is, BTW, easy to add a non-method subroutine to the object's data structure when using hash-based objects, but that could create more confusion than it solves.

Just for kicks, I'll give you a link to Hubba Bubba®. It may not be where you got the words, but anyone who grew up chewing this Wrigley® product will recognize the name on sight.

  • Comment on Re^4: Can I add methods to an existing object?