making a class in irb

13 views
Skip to first unread message

Sidney Reilley

unread,
Nov 19, 2021, 12:38:06 PM11/19/21
to
Ruby noob here! Using irb to learn.
created a sample class with 2 instance vars.
tried to access the vars. NO JOY!
Forgot to include the attr_reader.
Is there a way to amend/update a class in the irb?
Or do I have to re-type the entire class over again?
TIA ...

BeeRich33

unread,
Nov 20, 2021, 2:39:22 PM11/20/21
to
On Friday, November 19, 2021 at 12:38:06 PM UTC-5, Sidney Reilley wrote:
> Ruby noob here! Using irb to learn.

Best to use a different environment.

- install the filewatcher gem
- create a test file named app.rb with proper ruby headers at the top
- create an alias in your .bash_profile like this:

kk='filewatcher "/users/sidney/app.rb" "clear; ruby /users/sidney/app.rb"'

in the terminal, type kk, and it will be running. When you edit the file and save it, it will run in the terminal. This is a much better option than irb.

Sidney Reilley

unread,
Nov 20, 2021, 11:24:36 PM11/20/21
to
Good stuff! Thx for heads up for this useful solution.
Reply all
Reply to author
Forward
0 new messages