KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've been just going through PragProg Continuous Testing With Ruby , where they talk about invoking IRB in context of current class to inspect the code manually. However, they quote that if you invoke IRB.start in a class, self is predefined, and refers to the object we were in when start was called which isn't true in my case. Even for very simple example like a = "hello" require 'irb' ARGV.clear # otherwise all script parameters get passed to IRB IRB.start When I try to access the a variable, I get the obvious NameError: undefined local variable or method `a' for main:Object It works only when I change a to global variable $a = "hello" require 'irb' ARGV.clear # otherwise all script parameters get passed to IRB IRB.start then I can access it irb(main):001:0> $a => 1 Is there any way around this to access local and instance variables in the current class?
Tags (comma-separated)
Save Edits
Cancel