What is the best way to write a function (or something DSLish) that will allow me to write this code in Ruby. How would I construct the function write_pair?
This is a simple solution:
def write_pair(variable) puts variable + eval(variable) end
This is more readable:
def write_pair(variable) puts 'A' * 100 puts variable + ': ' + eval(variable).inspect puts 'Z' * 100 end
Invocation:
write_pair "variable"