Strings And Text

Greeting A User

This example uses a default parameter and interpolation.

fn greeting(name is string, punctuation is string = "!") is string (
	return "Hello, ((name))((punctuation))"
)

Constructing Multiline Text

Typical represents multiline text using ordinary strings, newline escapes, and concatenation.

fn addressLabel(name is string, city is string, country is string) is string (
	return name + "\n" +
		city + "\n" +
		country
)

Describing A List

This function combines array iteration, branching, mutation, and interpolation.

fn bulletList(items is string[]) is string (
	result is var string = "Items:"

	items each item index (
		position = index + 1
		result += "\n((position)). ((item))"
	)

	return result
)

Formatting A Small Report

This denser string example keeps each meaningful operation on its own line.

fn scoreReport(name is string, scores is int[]) is string (
	total is var int = 0

	scores each score (
		total += score
	)

	count = scores.length
	average = total / count

	return "Student: ((name))\n" +
		"Scores: ((scores))\n" +
		"Average: ((average))"
)