Library reference

Repeat a piece of text

Repeat the same text a given number of times. The new string contains each copy in order.

repeat

Simple example

Repeat x three times.

Start'x' · 3
Resultxxx
lesson.jl
function main()
    println(repeat("x", 3))
end

main()
Output
xxx
Advertisements

Everyday examples

Print four star marks on a prize ticket.

Start'*' · 4
Result****
lesson.jl
function main()
    println(repeat("*", 4))
end

main()
Output
****

Draw a six-character divider for a receipt.

Start'-' · 6
Result------
lesson.jl
function main()
    println(repeat("-", 6))
end

main()
Output
------

Make a three-part red-blue pattern for a ribbon label.

Start'RB' · 3
ResultRBRBRB
lesson.jl
function main()
    println(repeat("RB", 3))
end

main()
Output
RBRBRB
Run the example
Terminal
julia lesson.jl
Official documentation