Ruby Equivalent of Python "_"
In Python, you can use the _
field to grab the last computed value. That's really useful in IDLE. Does Ruby have an equivalent for IRB?
An example from Python:
>>> 2 + 2
4
>>> _
4
>>> "Me " + "You"
'开发者_运维知识库Me You'
>>> _
'Me You'
_ isn't working?
host:~ user$ irb
irb(main):001:0> s = "test"
=> "test"
irb(main):002:0> puts _
test
=> nil
In IRB you can use _
as well.
精彩评论