如何检查方法的关键字参数

时间:2015-03-18 22:10:17

标签: ruby

鉴于以下Ruby 2.x方法,我如何检查关键字参数?

def for_account(token_id: nil, email: nil, password: nil)
  puts "arguments are: ??"
end

1 个答案:

答案 0 :(得分:1)

def for_account(token_id: nil, email: nil, password: nil)
  puts "arguments are: ??"
end

p method(:for_account).parameter
# => [[:key, :token_id], [:key, :email], [:key, :password]]