Standard Library

ScarScript includes built-in functions and methods. Module functions are called with their module name; modules are resolved by the compiler and do not need explicit imports.

Built-in functions

FunctionDescription
print(args...)Prints values to standard output. Supports string interpolation.
log.info(args...)Writes an info-level message to standard error.
log.error(args...)Writes an error-level message to standard error.
val user = "Ada" print("Welcome, {user}") log.info("Application started")

String methods

MethodReturnsDescription
trim()strRemoves leading and trailing whitespace.
toUpper()strConverts letters to uppercase.
contains(sub: str)boolChecks whether the string contains a substring.
len()intReturns the UTF-8 byte length.
val greeting = " hello " print(greeting.trim()) print(greeting.toUpper()) print(greeting.contains("ell"))

len() counts bytes, not user-perceived Unicode characters.

Array methods

MethodDescription
add(value)Appends an element; requires a mutable array.
remove(index)Removes the element at an index; requires a mutable array.
len()Returns the number of elements.
mut names: str[] = ["Ada", "Lin"] names.add("Grace") names.remove(0) print(names.len())

Map methods

len() returns the number of map entries. For string-keyed maps, field syntax is shorthand for key lookup:

val scores: map[str: int] = {"ada": 10} print(scores.len()) print(scores.ada) // same as scores["ada"]

See Built-in Modules for filesystem, environment, math, and time functions.