Source text and comments
moon source is UTF-8 and whitespace is not significant. A semicolon may separate statements on one line. // starts a line comment; /* ... */ comments may nest. A run of /// immediately before a declaration becomes its documentation.
Identifiers start with a letter or underscore, followed by letters, digits, or underscores. Comments may appear between tokens, so removing one never joins its neighbours.
/// Returns a small greeting.
fn greeting() -> string {
/* outer /* nested */ comment */
"Hello"
}
fn main() {
let _name2 = greeting(); println(_name2) // line comment
}
Examples use the moon toolchain version shown beside each result.
Output & diagnostics
Edit the source, then Check or Run. Ctrl/⌘+Enter checks.
Ctrl/⌘+Enter checks the current lesson.