repeat()

Repeat a string multiple times.

Signature

repeat(string, count)

Parameters

Returns

String repeated the specified number of times

Examples

Basic repetition:

print(repeat("x", 5))               // "xxxxx"
print(repeat("ab", 3))              // "ababab"

Creating visual patterns:

print(repeat("-", 20))              // "--------------------"
print(repeat("*", 10))              // "**********"

Building output with repetition:

indent = repeat(" ", 4)
print(indent .. "item1")
print(indent .. "item2")

Zero and one repetitions:

print(repeat("x", 0))               // ""
print(repeat("hello", 1))           // "hello"

See Also