Repeat
Returns a copy of the contents laid down N times.
Module: Text
Signature
rux
func Repeat(self, count: uint) -> String;Parameters
| Name | Type | Description |
|---|---|---|
count | uint | How many times to lay the bytes down. |
Returns
A new String holding the receiver's bytes count times over, in a block of its own. The receiver is left untouched. Repeating zero times, or repeating the empty string, yields the empty string.
The block is sized up front — it goes through a StringBuilder built with WithCapacity — so this costs one allocation rather than one per round.
Example
rux
import Text::String;
var dash = String::From("-");
var rule = dash.Repeat(20); // "--------------------"
rule.Length(); // 20
rule.Free();
dash.Free();See also
String— the string type+— join two different stringsStringBuilder::WithCapacity— the one allocation this leans on