我怎么能在这里做他们正在谈论的事情,但是在Ruby中呢?
你会如何对对象执行此功能?你将如何做一个全局函数(参见jetxee 在上述帖子中的回答)?
示例代码:
event_name = "load"
def load()
puts "load() function was executed."
end
def row_changed()
puts "row_changed() function was executed."
end
#something here to see that event_name = "load" and run load()
Run Code Online (Sandbox Code Playgroud)
更新: 你如何得到全球方法?还是我的全球职能?
我试过这个额外的一行
puts methods
Run Code Online (Sandbox Code Playgroud)
和load和row_change未列出的地方.