我有一个循环/遍历某些东西的函数,我希望它接收对设置停止条件/做某事的函数的引用。例如,在一个类中:
def a(func_stop,i)
ret = nil # default
while(i < 0 )
if (func_stop(@lines[i]))
ret = i
break
end
end
return ret
end
这个想法是我可以传递对函数的引用,有点像 PERL'S
func1(\&func, $i);
我看过,但没有找到这样的东西。谢谢