Built-in Functions
Harbor has one built-in function: print. The
respond keyword also uses call syntax but is a language
keyword, not a function.
print(value)
Prints a value to standard output followed by a newline.
| Parameter | Type | Description |
|---|---|---|
value | String or Number | The value to print |
print("Hello, world!")
print(42)
print(10 + 20) Output:
Hello, world!
42
30 print takes exactly one argument. It works with strings and
numbers. Passing other internal types (like None) may produce
no output.
respond
While respond uses function-call-like syntax, it is a
language keyword. It can only be used inside route handlers.
get "/" {
respond "OK"
} respond sends its argument as the HTTP response body with a
200 OK status. The argument must evaluate to a string.
Both of these forms are valid:
respond "hello"
respond("hello")
See Routes for more details on using
respond in handlers.