Calling a function if it exists?

Started by EK.IceFlake, Sep 17, 2016, 06:47 PM

Previous topic - Next topic

EK.IceFlake

After so many servers I have made, I got some experience in how to make your code tidy and extensible. I am writing a modular interface which will have to call lots of functions for an event, but only if they exist.

Any idea how to do it?

Thanks

EK.IceFlake


.

if (my_table/class/instance/whatever.rawin("somefunc"))
    my_table/class/instance/whatever.rawget("somefunc").call(this, "sup?");

Worst design decision you could make. Because it involves iterating over a container multiple times to locate something.
.

EK.IceFlake

Quote from: . on Sep 18, 2016, 11:42 AMif (my_table/class/instance/whatever.rawin("somefunc"))
    my_table/class/instance/whatever.rawget("somefunc").call(this, "sup?");

Worst design decision you could make. Because it involves iterating over a container multiple times to locate something.
Wow... I was experimenting and tried .rawexists instead of .rawin
:v