N5ken's technical blog

Just another WordPress.com site

IRB Trick

IRB subsessions let you try things without ending or affecting any of your existing subsessions. The commands to work with subsessions are:

irb start a new subsession
jobs list subsessions
fg # switch to a subsession
kill # kill a subsession

>> my_string = "foo"
=> "foo"
>> irb
>> my_string
NameError: undefined local variable or method `my_string' for main:Object
from (irb#1):1
>> jobs
=> #0->irb on main (#: stop)
#1->irb#1 on main (#: running)
>> fg 0
=> #, @signal_status=:IN_EVAL, @scanner=#>
>> my_string
=> "foo"
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: