API Reference › Os › Os.env_or
method

Os.env_or

Os.env_or(name, fallback) -> string

Reads an environment variable, returning fallback when it is not set — the null-safe way to read optional configuration. The result is always non-null, so it is safe to use directly.

Parameters

namethe variable name
fallbackthe value to use when the variable is unset

Example

program EnvOr {
  entry {
    let assets = Os.env_or("LUDIC_ASSETS", "assets/")
    print(len(assets))
  }
}
← All symbols