Strings
A string in Dyon is a variable that stores UTF-8 bytes.
This represent text.
The type is str.
Use double quotes to write a string:
#![allow(unused)] fn main() { a := "hi!" }
The \ symbol escapes special characters:
\n- New line\t- Tab\"- The"character\\- The\character\r- Moves to beginning of line without creating a new line\u005c- Unicode character by 4 hexadecimal code
The + operator joins two strings together:
#![allow(unused)] fn main() { name := "Santa" title := "hi " + name }
The str function converts a value into a string:
#![allow(unused)] fn main() { age := 58 println("Bilbo is " + str(age) + " years old!") }
Some useful functions for strings
fn str(any) -> str- convert a variable to a stringfn read_line() -> str- read line from standard inputfn trim(str) -> str- trims away whitespace at both sidesfn trim_left(str) -> str- trims away whitespace at left sidefn trim_right(str) -> str- trims away whitespace at right sidefn json_string(str) -> str- creates a JSON stringfn str__color(vec4) -> str- HTML hex color stringfn chars(str) -> [str]- characters of a string