A
Alexey Verkhovsky
Cross-posted from Ruby Forum:
http://www.ruby-forum.org/bb/viewtopic.php?t=62
----
How do you get the value of the last expression entered in irb?
SML/NJ puts it in the variable 'it', Python uses '_', I think.
So you can do something like this:
Code:
Can you do this in Irb? It's very useful for evaluating expressions
interactively, without cluttering up your symbol table (e.g. when
evaluating something piece-by-piece to see how it's working.)
For example, I just did
Code:
YAML::load(<<END)
# ... some YAML here ...
END
and got the right result, then realised I had no way of using it.
http://www.ruby-forum.org/bb/viewtopic.php?t=62
----
How do you get the value of the last expression entered in irb?
SML/NJ puts it in the variable 'it', Python uses '_', I think.
So you can do something like this:
Code:
=> it = 426*9 => it = 54
it - 12
Can you do this in Irb? It's very useful for evaluating expressions
interactively, without cluttering up your symbol table (e.g. when
evaluating something piece-by-piece to see how it's working.)
For example, I just did
Code:
YAML::load(<<END)
# ... some YAML here ...
END
and got the right result, then realised I had no way of using it.