Newbie Question: irb

M

Mike Halloran

How can I access the previous result of an evaluation in the irb
debugger.

For example:
3 <-- I want to access this result
8


=================
In lisp it would be:
8

Anyway, thanks in advance for the help,

Mike
 
S

Skye Shaw!@#$

How can I access the previous result of an evaluation in the irb
debugger.

You must enable EVAL_HISTORY. Once you do so, you can access the
return value of the last expression via "_".
See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/102888

The token "__" (2 underscores) will give you access to the currrent
IRB::History object. Unfortunatley, it's not a full fledged array.

irb(main):001:0> 1+1
=> 2
irb(main):002:0> 2+2
=> 4
irb(main):003:0> __[-2]+1
=> 3
irb(main):004:0> __[-1]*3
=> 9
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Help for a newbie 13
self in irb versus script 3
irb question 8
irb newbie question 3
irb problem 1
Driving irb from IO.popen 5
Inconsistency between irb and Win7 cmd 1
Using gems in a script or irb 2

Members online

No members online now.

Forum statistics

Threads
474,263
Messages
2,571,312
Members
47,987
Latest member
Gaurav

Latest Threads

Top