Print "Hello World." leaves a "Hello World.nil". What is the.nil all about?


#1

What is the .nil all about?


#2

Hey Tterminal,

A quick search yields a bunch of helpful results. This answer seems especially helpful:

The Ruby console doesn’t always print nil at the end, but it does automatically show the value of the last statement or expression that is executed in your script. puts happens to return nil, so if you do puts "hello", you’ll see hello, followed by nil. However, if you say x = 5, you’ll see 5 instead of nil, because that’s now the value of the last statement.
- Why is all my code printing nil at the end? It's very foreboding.