views:

37

answers:

1

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?

A: 

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

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