Ruby 코드를 효과적으로 디버깅하기 위한 Byebug 완벽 가이드
Byebug는 Ruby 2.0 이상을 지원하는 강력한 C 확장 기반의 커맨드라인 디버거로, 실행 중인 코드의 상태를 정밀하게 검사할 수 있습니다.
Ruby 코드를 효과적으로 디버깅하기 위한 Byebug 완벽 가이드
Byebug는 Ruby 2.0 이상을 지원하는 강력한 C 확장 기반의 커맨드라인 디버거로, 실행 중인 코드의 상태를 정밀하게 검사할 수 있습니다.
Weirdness trying to modify #Ruby's default #𝚒𝚗𝚜𝚙𝚎𝚌𝚝 method. If I don't have an #𝚒𝚗𝚜𝚙𝚎𝚌𝚝 method in my #class, I get the usual
"#<𝚌𝚕𝚊𝚜𝚜𝚗𝚊𝚖𝚎:𝚒𝚗𝚜𝚝𝚊𝚗𝚌𝚎 @𝚒𝚟𝚊𝚛=𝚟𝚊𝚕𝚞𝚎, @𝚘𝚝𝚑𝚎𝚛_𝚒𝚟𝚊𝚛=𝚟𝚊𝚕𝚞𝚎>"
But if I define one like this,
def inspect
defval = super
return defval
end
what I get is
"#<𝚌𝚕𝚊𝚜𝚜𝚗𝚊𝚖𝚎:𝚒𝚗𝚜𝚝𝚊𝚗𝚌𝚎 ...>"
And I get anomalous results in the #byebug debugger, defval gets the above result. But if I enter "defval = super" by hand in the debugger, I get the original default output from 𝚒𝚗𝚜𝚙𝚎𝚌𝚝. ?
When debugging #ruby, I always struggled to get #byebug to enter the contents of a block, painstakingly stepping through internal methods and watching out for the yield. If you've ever debugged #Rails and/or callbacks, you'll know this pain.
Today, I learned you can just type `c <line number>` to jump straight into the block while skipping all of the plumbing that yields to it.
🐜 🚫 👍