Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Strings

import Lait
#lait

Values of type String are given using double quotes. Strings support one basic operation: concatenation, given by ++, which puts the two strings together.

#eval "hello" -- "hello">> "hello"
#eval "hello" ++ "world" -- "helloworld">> "helloworld"

We can convert values to a String using the toString function:

#eval toString 42>> "42"
#eval toString true>> "true"

Here, toString has a polymorphic type, which means it can accept arguments of multiple types; e.g., Int, or Bool as above. We will see more about polymorphism here.