You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var instance, className;
for className in ["A", "B"] {
let instance = new {className}();
//or
if className == "A" {
let instance = new A();
} else {
let instance = new B();
}
instance->execute();
instance->another();
}
class A {
public function execute() {
echo "A";
}
public function another() {
echo "Aa";
}
}
class B {
public function execute() {
echo "B";
}
public function another() {
echo "Bb";
}
}
Both A and B have the "execute" and "another" method.
Result: The function execute of A instance run twice times.
The function execute of B doesn't runs.
The text was updated successfully, but these errors were encountered:
We only see part of the implementation of A, and none of B, so it's difficult to say where the problem is being introduced. Can you provide a more complete example?
Example:
Both A and B have the "execute" and "another" method.
Result: The function execute of A instance run twice times.
The function execute of B doesn't runs.
The text was updated successfully, but these errors were encountered: