append method

String append(
  1. String text, [
  2. int count = 1
])

Appends text to the end of this string, repeated count times.

Handy for padding, building repeated patterns, or tacking suffixes onto a base string without dealing with string concatenation.

Example:

'Hello'.append(' World')      // 'Hello World'
'x'.append('-', 3)            // 'x---'
'file'.append('.bak')         // 'file.bak'

Implementation

String append(String text, [int count = 1]) {
  return '$this${text * count}';
}