Replace this line with your code.
After i print something, on the console it shows what i printed but there is "nil" written at the end of every sentence
This question pops out from time to time since... this course was published. Someone should add the explanation at the beginning of the course or just delete this feature.
nil stands for nihil, nothing.
This is the common feature of the REPL's (read - eval - print loop) and it's very helpful (in fact).
Let's say that you have a Ruby console in front of you and you simply want to make some calculations (you are a programmer, a calculator is not for you). So you just type (
>> is the input indicator):
>> 28**2 => 784
Oh, you got the result! Ruby returns the value of the last evaluated expression. Great, right?
But what happens if you want to print out the result to the console?
>> print 28**2 784 => nil
Ok, we got the result, but why there is a
nil? Because this is what the
In the normal environment, the return value of the last evaluated expression is marked by the
=> (or similar) indicator.
For clarification -> Codecademy is not a normal environment.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.