easy and clean puts in ruby -


i have situation, want debug in ruby. have output console "puts".

following example:

testvariable = 4 puts testvariable 

the output of course:

4 

now have lot of outputs , therefore write this:

testvariable = 4 puts "testvariable= " + testvariable 

the output then:

testvariable= 4 

now easy case hope shows question is. possibility exist???

testvariable = 4 prettyputs testvariable 

and output directly

testvariable = 4 

i hope understand, "problem" is? of course isnt lot of work write complete string down, want know if there fast , easy possibility?

this duplicate to: ruby: getting variable name

in short: can not name of variable, can put string or symbol name of variable want display

def prettyputs(symb, the_binding)   var_name  = symb.to_s   var_value = eval(var_name, the_binding)   puts "#{var_name} = #{var_value.inspect}" end  toto=1 prettyputs "toto",binding 

or

prettyputs :toto,binding 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -