Skip to content

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!"
end
  • hello is a function returning the String, as the canonical hello property is, rather than a main that prints it. A value can be asserted; printed output would need io.replay to check.
  • The string literal is the whole body: a function’s last expression is its result.