Can someone please summarize what/when is $DEBUG used. I am unfamiliar with it, and had no luck finding documentation (the Class Thread documentation and Module Signal documentation).
These are examples that are not clear to me what's going on:
p @ivar if $DEBUG
and:
Signal.trap("USR1") do
$debug = !$debug
puts "Debug now: #$debug"
end
Those two are totally different. The first is a debugging line executed only if $DEBUG is set; $DEBUG is set if you pass the command-line argument -d to ruby.
The second is flipping a $debug variable (different case!!), which is specific to the program. When you hit the process with a SIGUSR1 signal, it will change the debug mode (useful for getting it to print debugging information only sometimes).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With