Category talk:Wren-str: Difference between revisions
→Source code: Replaced Str.repeat method with a much more efficient version.
(Added Str.fromBytes and Str.fromCodePoints methods. Removed type aliases which are no longer needed.) |
(→Source code: Replaced Str.repeat method with a much more efficient version.) |
||
Line 364:
chars[j] = t
return Strs.concat(chars)
static repeat_(s, reps) {▼
var rs = ""▼
for (i in 0...reps) rs = rs + s▼
}
// Returns 's' repeated 'reps' times.
if (!(s is String)) s = "%(s)"
if (!(reps is Num && reps.isInteger && reps >= 0)) {
Fiber.abort("Repetitions must be a
}
▲ var rs = ""
▲ for (i in 0...reps) rs = rs + s
▲ if (reps == 0) return ""
} else {
if (reps % 2 == 1) rs = rs + s
}
return rs
}
// Splits a string 's' into chunks of not more than 'size' characters.
|