Greeter Program

In earlier chapters, we have looked at building a simple Hello World program. Here we will expand that example slightly in order to ask the user their name before saying hello.

This example shows the usage of variables and comments, as well as printing out multiple elements in a line.

# This is a comment
echo "What's your name? "
var name: string = readLine(stdin)
echo "Hi, ", name, "!"

Compiling and running this program using nim c -r greeter.nim will yield an output similar to:

What's your name?
Euan
Hi, Euan!