Repeat a string: Difference between revisions

Content added Content deleted
m (→‎{{header|Go}}: small clarification)
Line 396: Line 396:


=={{header|Go}}==
=={{header|Go}}==
<lang go>fmt.Println(strings.Repeat("ha", 5)) # ==> "hahahahaha"</lang>
<lang go>fmt.Println(strings.Repeat("ha", 5)) // ==> "hahahahaha"</lang>
There is no special way to repeat a single character, other than to convert the character to a string. The following works:
"Characters" are just strings of length one.
<lang go>fmt.Println(strings.Repeat(string('h'), 5)) // prints hhhhh</lang>


=={{header|Groovy}}==
=={{header|Groovy}}==