How to I get the terminal to show return values? (Ruby)
I'm using repl.it to work through some Ruby exercises. If I write in the editor, for example...
x = 2+5
7 will appear in the terminal.
But if I write in the editor...
...nothing appears in the terminal. It runs, because the terminal skips to a new line, but the value does not appear. Why?
I'm not as familiar with Ruby, but I assume that
return in ruby is the same as
return in every other language. Generally,
return is used in a function to send a value back to its function call. Also, output generally only shows in the console when you explicitly tell it to do so (via
p in ruby). Since you aren't telling the program to print anything to the console, it simply doesn't.
If you have a repl we can look at, I can give some more examples.