String operations that work directly on values on the stack. To push strings, see the Push Functions section; to read them, see the Get Functions and Value Conversion sections.

tea_concat

Signature

void tea_concat(tea_State* T, int n);
[-n, +1, m]

Description

...str1...strN
...str

Concatenates the top n values of the stack, which must all be strings, and replaces them with the resulting string. This is the + string concatenation of Teascript, at the C API level.

If n is 0, an empty string is pushed, the neutral element of concatenation. If n is 1, nothing is done, since the single value is already the result.

Parameters

T
Teascript state
n
Number of values to concatenate

Errors

May raise a memory error.

Example

tea_push_string(T, "hello");
tea_push_string(T, ", ");
tea_push_string(T, "world");
tea_concat(T, 3);               /* ["hello, world"] */

tea_concat(T, 0);               /* ["hello, world", ""] */

See also

tea_push_string, tea_push_fstring, tea_to_string