repeat method

String repeat(
  1. int count
)

Repeats the string count times and returns the result.

Equivalent to using the * operator but more readable in some contexts.

Example:

'ha'.repeat(3)          // 'hahaha'
'-'.repeat(5)           // '-----'
'x'.repeat(0)           // ''

Implementation

String repeat(int count) {
  return this * count;
}