Ruby等效的Python"_"

Mik*_*ike 3 ruby python irb python-idle

在Python中,您可以使用该_字段来获取最后一个计算值.这在IDLE中非常有用.Ruby有IRB的等价物吗?

Python的一个例子:

>>> 2 + 2
4
>>> _
4
>>> "Me " + "You"
'Me You'
>>> _
'Me You'
Run Code Online (Sandbox Code Playgroud)

yan*_*yan 11

_不工作?

host:~ user$ irb
irb(main):001:0> s = "test"
=> "test"
irb(main):002:0> puts _
test
=> nil
Run Code Online (Sandbox Code Playgroud)


sep*_*p2k 5

_在 IRB 中您也可以使用。