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-forum.com/\.
In irb, "_" represents the previous result, and to go farther back you can just assign results to variables.
irb(main):001:0> a = 1 + 2
=> 3
irb(main):002:0> 5
=> 5
irb(main):003:0> _ + a
=> 8
Mike Halloran wrote:
···
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
Skye_Shaw
(Skye Shaw!@#$)
3
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
···
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.