Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^2: isa() on any scalarby chromatic (Archbishop) |
on Jun 10, 2005 at 18:56 UTC ( [id://465644]=note: print w/replies, xml ) | Need Help?? |
No, don't do that. Assume that UNIVERSAL::new existed. Would you suggest always creating objects with UNIVERSAL::new( $class_name, %data ); too? Try instead:
This has the advantage of allowing subclasses of Node to override isa() as they see fit, of allowing objects that perform the Node role (see Class::Roles, for example) to work appropriately, and of catching an error if $value is an invalid invocant. It also avoids calling a parent class method specifically on a potential instance of a derived class, which is a bad idea. Update: Expanded code slightly.
In Section
Seekers of Perl Wisdom
|
|