Ruby Tip: Reference to previous line

Travis Winters showed me a nifty trick to reference to previous line in rib by using the symbol _ (aka underscore). Look at the example below:

$ irb
ruby-1.9.2-p290 :002 > "hello world"
ruby-1.9.2-p290 :002 > @hello = _
ruby-1.9.2-p290 :002 > puts @hello
hello world
 => nil

About Jones Lee

Nothing much about me..

Leave a comment