I have very often the situation, that i want to Debug something in Ruby. Then i have an output to the console with "puts".
Following example:
Testvariable = 4
puts Testvariable
The output is of course:
4
Now i have a lot of outputs and therefore i write very often something like this:
Testvariable = 4
puts "Testvariable= " + Testvariable
The output is then:
Testvariable= 4
Now this was a very easy case but i hope that it shows what my question is. Does a possibility like this exist???
Testvariable = 4
prettyputs Testvariable
and that the output is directly
Testvariable = 4
I hope you do understand, what my "problem" is? Of course it isnt a lot of work to write the complete string down, but i just want to know if there is a fast and easy possibility?
There's a gem called "ap"
awesome_print
which does more or less what you want.The case you listed here doesn't really do the question justice, and probably if you are "puts"ing things, you might want to learn more about debugging and testing tools.
From the AP documentation, consider the following:
Printing this with Ruby's builtin
puts
would be a mess, but AP prints the following:I realise that's not exactly what you want, but perhaps the following is equally useful:
since you named it uppercase, I'm going to assume it's a class or a constant, and you want to see it's type, which
.inspect
will do for you.