Probably a really basic question, but I'll ask anyways. I tried googling my question but am having trouble getting results because I do not know the keywords to search. Any links for more info would be appreciated.

So, what happens to the value of a statement after execution? Maybe it's just because I'm in IRB that I am confusing myself. Example, if I am in IRB (Interactive Ruby) and execute the following: "Hello World"

Does the value disappear, forever lost? Or is it stored temporarily somewhere where it could be accessed? Thanks in advance!

有帮助吗?

解决方案

The value is stored to a temporary variable _ which always stores the last command run in IRB.

In actual script execution, the value would float away into the netherlands. If you wanted to save it, you should assign it to a variable.

hello_world = "Hello World!"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top