Quirrel4.41.0

types.String.concat

Method on every string
pure string.concat(value, ...): any

Joins its arguments into one string, with str between each pair.

The binding carries no declaration string, so the VM cannot report parameter names. The names above are from this page; the types and attributes still come from the VM. The VM also cannot tell an optional parameter from a variadic tail here, so read the brackets and any trailing ... from the prose below, not from the signature.
examples/types/string/concat-basic.nut
let separator = ", "
println("separator.concat(\"sword\", \"shield\", \"potion\") =", separator.concat("sword", "shield", "potion"))
Output:
separator.concat("sword", "shield", "potion") = sword, shield, potion

Parameters

valueanythe first item to join
...anyfurther items to join repeats

Return value

value and the rest, each converted with tostring(), joined with str between each pair. An item can be any type, not only a string.

Notes

Takes 1 or more arguments: at least one item is required. This is a real, unbounded vararg - unlike types.String.join, which takes its items from an array and caps itself at one extra argument, concat takes the items directly as arguments and accepts any number of them.

Example

examples/types/string/concat.nut
// items can be any type: each is converted with tostring().
println("\"-\".concat(1, \"b\", true) =", "-".concat(1, "b", true))
println("\"-\".concat(\"solo\") =", "-".concat("solo"))
Output:
"-".concat(1, "b", true) = 1-b-true
"-".concat("solo") = solo

See also

joinJoins the items of arr into one string, with str between each pair.
substSubstitutes {0}, {1}, ... and {name} placeholders in str with the given values.
stringclass index