Sam Sungshik Kong [mailto:ssk / chol.nospam.net] wrote:

> <nobu.nokada / softhome.net> wrote in message 
> news:200406082253.i58MrAwl019111 / sharui.nakada.niregi.kanuma.t
ochigi.jp...
> Hi,
>
> At Wed, 9 Jun 2004 02:03:37 +0900,
> Dennis Ranke wrote in [ruby-talk:102807]:
> > > In Python, I use '_'(underscore) for the last returned value.
> > >>>> print "Hello"
> > > "Hello"
> > >>>> x = _
> > >>>> print x
> > > "Hello"
> > >
> > > What is the equivalent in Ruby?
> >
> > If you mean what's the equivalent in irb then my answer would be:
> >
> > IRB.CurrentContext.last_value
> >
> > But that's a bit cumbersome ;)
>
> EVAL_HISTORY enables _.
>
> $ grep HISTORY ~/.irbrc
> IRB.conf[:EVAL_HISTORY] = 1000
> IRB.conf[:SAVE_HISTORY] = 100
>
> $ irb
> irb(main):001:0> 2+2
> => 4
> irb(main):002:0> _
> => 4
> irb(main):003:0>
>
> --
> Nobu Nakada
>
>
> Hi!
> 
> Thanks for the reply.
> 
> However, I cannot do it.
> Could you elaborate a little bit more?
> 
> I use Windows XP.
> And I brought up 'irb' and tried the following:
> 
> irb(main):001:0> irb.conf[:EVAL_HISTORY]=1000 
> irb#1(main):001:0> irb.conf[:SAVE_HISTORY]=100 
> irb#2(main):001:0> 3+3 => 6 irb#2(main):002:0> _ => nil 
> irb#2(main):003:0>
> 
> What's wrong?
> 
> Thanks again.
> 

I followed the examples (great tip fr humble Nobu).

c:\family\ruby>ver

Microsoft Windows XP [Version 5.1.2600]

c:\family\ruby>type .irbrc
IRB.conf[:EVAL_HISTORY] = 1000
IRB.conf[:SAVE_HISTORY] = 100


c:\family\ruby>irb
irb(main):001:0> 2+2
=> 4
irb(main):002:0> _*4
=> 16
irb(main):003:0>

if you put .irbrc in your current dir, irb will find it for sure.


> Sam

I moved your top post, Sam :-)

kind regards -botp