Skip to content

Instantly share code, notes, and snippets.

@cmhobbs
Created November 13, 2012 17:29
Show Gist options
  • Save cmhobbs/4067164 to your computer and use it in GitHub Desktop.
Save cmhobbs/4067164 to your computer and use it in GitHub Desktop.
fancy debug method (public)
DEBUG = true
def debug(msg, obj = nil)
msg = ("== DEBUG: #{msg}") unless (msg.class != String)
$stderr.puts msg if DEBUG
$stderr.puts obj if (DEBUG && obj != nil)
end
irb(main):006:0> h = {:foo => "bar", :baz => "quux"}
=> {:foo=>"bar", :baz=>"quux"}
irb(main):007:0> debug "i'm a debug statement"
== DEBUG: i'm a debug statement
irb(main):008:0> debug "here's a hash", h
== DEBUG: here's a hash
{:foo=>"bar", :baz=>"quux"}
@cmhobbs
Copy link
Author

cmhobbs commented Nov 13, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment