如何根据方法的名称动态调用方法?
class MyClass def foo; end def bar; endendobj = MyClass.new str = get_data_from_user # e.g. `gets`, `params`, DB access, etc.str #=> "foo"# somehow call `foo` on `obj` using the value in `str`.
哔哔one
泛舟湖上清波郎朗
随时随地看视频慕课网APP
相关分类