[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Newbie Question: irb

skibud2

7/23/2007 10:32:00 PM

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

For example:

>> 1 + 2
3 <-- I want to access this result

>> 5 + {some expression which is '3'}
8


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

>>(+ 1 2)
3
>> (+ 5 *) <-- use a star to grab one result back
8
>> (+ 5 **) <-- use a double start to grab two results back
8

Anyway, thanks in advance for the help,

Mike
--
Posted via http://www.ruby-....

1 Answer

skye.shaw

7/24/2007 3:43:00 AM

0

On Jul 23, 3:32 pm, Mike Halloran <mike.hallo...@gmail.com> wrote:
> 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-t...

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