Page 1 of 1

log outputs nil at the end, bug?

Posted: Sep 5th, '18, 11:16
by MSandro
The log commands outpus a nil in a new line after all other argumens, but only if I've started GP in REPL mode. Why? Is this a bug? I am a bit confused.

Re: log outputs nil at the end, bug?

Posted: Jun 3rd, '19, 14:04
by JohnM
The "nil" you are seeing is probably the return value of whatever expression you evaluated in the REPL. For example:

Code: Select all

print 'hello!'
runs the command "print", which outputs the string 'hello' to the console. Since "print" is a command whose value is discarded when running as a block, it just returns nil. The REPL always prints the return value for any code that you type, so that's why you see "nil".

If you type an express that returns a value other than nil, such as:

Code: Select all

join 'hello' ', world!'
You'll just see the result of that expression:

Code: Select all

hello, world!