Language / Varargs (...args)

Varargs (...args)

Silk supports “varargs” parameters to accept a variable number of trailing arguments, used by std::io::print / std::io::println.

Full reference: varargs.

Syntax#

fn log (fmt: string, ...args: std::fmt::Arg) -> void {
  std::io::println(fmt, args);
}

Example#

import std::io;

fn main () -> int {
  std::io::println("hello {s} answer={d}", "world", 42);
  return 0;
}

See also#

Source repository · Edit this page · View Markdown