import debug for debug; class event { func init() { self._func = []; // callback functions list } func clear() { self._func.clear(); } func += (fn) { if(typeof(fn) != "function") debug.assert("wrong type"); if(!self._func.contains(fn)) self._func.push(fn); else debug.logError("已经存在这个方法"); } func -= (fn) { if(typeof(fn) != "function") debug.assert("wrong type"); self._func.remove(fn); } func () (...){ foreach(var fn in self._func) { fn(...); } } } /* var Say = new event(); Say += func(str) { io.print(str); } Say("hi"); Say.clear(); */