I have
a = 'a string'
b = 3
I use this common pattern:
puts "a: #{a}, b: #{a}"
I would like to do this with a method e.g.,
def puts_auto(*args)
str = args.map { |arg| "#{arg.object_name #{a}" }.join('')
puts str
end
where object_name
finds the name of the object that was used to create the arg. Is there such method like object_name
? Is there a way to print the value and the name of each argument from a splat argument list?