Search code examples
rubydebuggingruby-debug

How to evaluate a multi-line block in ruby-debug console


I would like to evaluate

def foo
  puts "you done got fooed"
end

in the ruby-debug console. It works fine fine with irb. But in ruby-debug, I can't get the reader to continue reading input after a newline.

I've even tried ending the line in a backslash.


Solution

  • you can enter irb from rdebug:

    (rdb:1) irb
    irb(main):001:0> self
    => main
    irb(main):002:0> def foo
    irb(main):003:1> puts "foo!"
    irb(main):004:1> end
    => nil
    irb(main):005:0> exit
    (rdb:1) p foo
    foo!
    nil
    (rdb:1)