How do you pass arguments to define_method?

后端 未结 4 877
走了就别回头了
走了就别回头了 2020-12-12 10:52

I would like to pass an argument(s) to a method being defined using define_method, how would I do that?

4条回答
  •  忘掉有多难
    2020-12-12 11:08

    With 2.2 you can now use keyword arguments: https://robots.thoughtbot.com/ruby-2-keyword-arguments

    define_method(:method) do |refresh: false|
      ..........
    end
    

提交回复
热议问题