I'm studying Ruby. I know that Ruby was heavily influenced by Smalltalk. Smalltalk IDEs offer image based persistence, which means one can add methods and classes from within the running image.
Is the same possible in Ruby's irb
?
I'm studying Ruby. I know that Ruby was heavily influenced by Smalltalk. Smalltalk IDEs offer image based persistence, which means one can add methods and classes from within the running image.
Is the same possible in Ruby's irb
?
Nah, that's smalltalk only. But you can use maglev ruby to get the smalltalk VM back.
You can use pry and its edit
command to edit code on the disk and the shell takes care of reloading. But you can't save the session, only the code you wrote to disk.
@Tass is slightly mistaken. Using Pry you can indeed edit methods you've written on the console, but only methods. For example:
pry(main)> def foo
pry(main)* "bar"
pry(main)* end
=> nil
pry(main)> edit-method foo
=> nil
## launches editor
pry(main)> class Foo
pry(main)* def bar
pry(main)* "qux"
pry(main)* end
pry(main)* end
=> nil
pry(main)> edit-method Foo#bar
=> nil
## launches editor
Both cases work, whereupon you can save and modify the method in your editor. However you can't do e.g. edit-class Foo
.
It does have at least one limitation, though:
pry(main)> class Foo; def bar; "baz" end end
=> nil
pry(main)> edit-method Foo#bar
Error: Pry can only patch methods created with the `def` keyword.
Weird.