Reputation: 445
I want to check if my class parent class has such property. And if yes, than access to it.
if ( $cast(this.get_parent(), agent_inst) && agent_inst != "NULL" )
if (agent_inst.vitf != "NULL")
vitf = agent_inst.vitf;
Now if agent_inst does not have vitf property, the simulator will give an error. So how I can check if agent_inst has the vitf property?
Thanks
Upvotes: 1
Views: 835
Reputation: 42748
You have the arguments to $cast backwards; the first argument is the target variable, the second is source. The way $cast works, you should have declared agent_inst
with a class type that has a vitf
property. The $cast only succeeds at run-time if the source object is type compatible with the target. Your code will not compile unless agent_inst.vitf
exists.
Upvotes: 1