Skip to content

print

Built-in function · Available everywhere, with no import

print shows values in the terminal, then starts a new line. It is usually the first thing a program does, and the quickest way to see what a value holds while a program runs.

print("Hello, world!")
print("Score:", 42) # prints Score: 42
print() # prints an empty line

print(values...)

Shows each value, separated by a space, then ends the line. It takes any number of values of any type, and none at all prints an empty line.

Text is shown as it is, without quotes. Every other value is shown the way it would appear inside "#{...}": numbers as written, lists in brackets, and a struct field by field, unless its type adopts Textual to choose its own form.

print([1, 2, 3], true, 2.5) # prints [1, 2, 3] true 2.5

The whole line is built before any of it appears, so if showing a value raises an error, nothing of that line is printed.

To build a line of text around values, interpolation is usually clearer than several arguments: print("#{name} scored #{points}"). To show values without ending the line, use write.