Strings

Strings

> Tutorial

Strings

Strings (character strings) are a type of value used to represent text.

A string is written between single or double quotes:

Operations on strings

Only one operator is available on strings: +, the concatenation operator, which "glues" two strings together:

Many functions are available for strings, in the "Strings" section of the documentation. The main ones are:

Examples:

Greet your opponent

Several standard functions use strings, such as getName, which returns the name of an entity. We are going to use it to greet our opponent on turn 1:

The say function makes your leek say something; it costs 1 TP . As you may have guessed, against an enemy named Domingo, our leek will say: "Hi Domingo!". Feel free to customize it, as long as you stay polite!

❓ Quiz

What is the result of the code "10" + 5 + "aa"?

"105aa" "15aa" "10aaaaaaaa" "15aaaaa"

What is the result of the code substring("eucalyptus", 4, 3)?

"lyp" "euc" "ptus" "euca"

Complete AI