This module contains utility functions for conversions, shortcuts, and language features.

Include using

var util = use("std:util");

Global Shortcuts

type_of and range are also registered as global built-in functions in Kyro and can be called directly anywhere without importing std:util.


to_string

to_string(value)

Converts a value into its string representation.

  • Parameters:
    • value (Any): The value to convert into a string.
  • Returns: (String) The string representation of the given value.
var util = use("std:util");

var s = util.to_string(42.0);

echo s; // "42"

to_number

to_number(value)

Converts a value into a number.

Conversion rules:

  • Number values are returned unchanged.
  • String values are parsed as numbers.
  • true converts to 1.
  • false converts to 0.
  • nil converts to 0.
  • Other types will raise a runtime error.

  • Parameters:

    • value (Any): The value to parse or convert to a number.
  • Returns: (Number) The numeric representation of the given value.
var util = use("std:util");

echo util.to_number("123"); // 123
echo util.to_number(true);  // 1
echo util.to_number(nil);   // 0

info

info()

Returns information about the current kyro runtime.

The returned object contains the following fields:

  • language
  • version

  • Parameters: None

  • Returns: (Any) An object containing the runtime parameters:
    • language: The string identifier of the language.
    • version: The current version of the kyro interpreter.
var util = use("std:util");

var info = util.info();

echo info.language;
echo info.version;