相关疑难解决方法(0)

有没有办法在Ruby中访问方法参数?

Ruby和ROR的新手并且每天都喜欢它,所以这是我的问题,因为我不知道如何谷歌它(我已经尝试:))

我们有方法

def foo(first_name, last_name, age, sex, is_plumber)
    # some code
    # error happens here
    logger.error "Method has failed, here are all method arguments #{SOMETHING}"    
end
Run Code Online (Sandbox Code Playgroud)

所以我正在寻找方法将所有参数传递给方法,而不列出每一个.因为这是Ruby我假设有一种方式:)如果它是java我会列出它们:)

输出将是:

Method has failed, here are all method arguments {"Mario", "Super", 40, true, true}
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails

94
推荐指数
6
解决办法
5万
查看次数

标签 统计

ruby ×1

ruby-on-rails ×1