It is possible to use methods as variables.
contract test {
import Runtime;
import Map;
global _counter:number;
global _callMap: storage_map<address, method<address>>;
constructor(owner:address)
{
_counter := 0;
}
public registerUser(from:address, amount:number)
{
local target: method<address>;
if (amount > 10) {
target := incCounter;
}
else {
target := decCounter;
}
_callMap.set(from, target);
}
public callUser(from:address) {
local target: method<address> := _callMap.get(from);
Call.method(target, from);
}
private incCounter(target:address) {
_counter += 1;
}
private subCounter(target:address) {
_counter -= 1;
}
}