Hello World
Answer the greeting “Hello, World!”.
Adapted from Exercism’s problem specification (MIT). Listed under Strings & Text.
// FILE: hello_world.nomi
//# The classic first program.
/// The greeting every program starts with.
pub fn hello() -> String
"Hello, World!"
end
// FILE: hello_world_test.nomi
import hello_world.hello
test "Say Hi!"
assert hello() == "Hello, World!"
endok Say Hi!
test result: ok. 1 passed, 0 failed
How it’s written
Section titled “How it’s written”hellois a function returning theString, as the canonicalhelloproperty is, rather than amainthat prints it. A value can be asserted; printed output would needio.replayto check.- The string literal is the whole body: a function’s last expression is its result.