开发者

Ruby equivalent to func_get_args()

开发者 https://www.devze.com 2023-01-07 22:42 出处:网络
In many PHP-application, when things are badly documented or weird implemented, the function func_get_args() comes to resque. It allows me to inspect (or print) what variables are passed along to a fu

In many PHP-application, when things are badly documented or weird implemented, the function func_get_args() comes to resque. It allows me to inspect (or print) what variables are passed along to a function

function poorly_documented($op, $a2, $a3 = 'default', $rest) {
  var_dump(func_get开发者_运维知识库_args());
  // ...
}

Allthough in Ruby I hardly ever need this, due to the nature of the language, I sometimes like to inspect what is passed along.

How would I do that in Ruby, or Ruby on Rails?


I believe this website should be of great service to you.

def add(*nums)
  total = 0
  nums.each {|num| total += num }
  total
end
# => 6
0

精彩评论

暂无评论...
验证码 换一张
取 消