Why is always nil in my output?


#1

I'm learning ruby on rails. Often there is this nil at the end of my output why is this how can i prevent this showing up in the result?


#2

When you were running your code in a real ruby environment this should not happen. Ruby console shows you the value of last statement. Since your print statement doesn't return a value it defaults to "nil".


#3

Thank you Ms Gloria good and important to know this wont happen in a real ruby environment.

You also said since my print statement doesn't return a value it defaults to nil. Below i uploaded a picture of the ruby course part i'm with at the moment, wen i run the code the puts statements outputs text so its not empty but still there is this nil showing up why is this?


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.