log outputs nil at the end, bug?

Report bugs. Post bug workarounds or fixes

Moderator: MSandro

Post Reply
Posts: 162
Joined: Jul 26th, '17, 21:12

log outputs nil at the end, bug?

Post by MSandro » Sep 5th, '18, 11:16

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.

Posts: 379
Joined: Sep 11th, '15, 14:42

Re: log outputs nil at the end, bug?

Post by JohnM » Jun 3rd, '19, 14:04

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!

Post Reply