How to checking wether an object has a specific method or not
Posted
by Ghommey
on Stack Overflow
See other posts from Stack Overflow
or by Ghommey
Published on 2010-04-15T16:46:19Z
Indexed on
2010/04/15
16:53 UTC
Read the original article
Hit count: 203
perl
Hey,
I want to use a method of an object.
Like $myObject->helloWorld()
.
However there are a couple of methods so I loop through an array of method names and call the method like this:
my $methodName ="helloWorld";
$myObject->$methodNames;
This works quite nice but some objects don't have all methods.
How can I tell wether $myObject
has a method called helloWorld
or not?
© Stack Overflow or respective owner