summaryrefslogtreecommitdiff
path: root/repeat.go
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2019-10-26 12:02:55 -0600
committermo khan <mo.khan@gmail.com>2019-10-26 12:02:55 -0600
commitfa865f49bba601bc1f9c49c0b0f56d58fa8f32b6 (patch)
tree6a1add445b4a397d4c8f598db631395e0e2a7b8f /repeat.go
parent1e52b71575b694e370e46c2cc81f322db1b176c2 (diff)
https://golang.org/pkg/strings/#Repeat
Diffstat (limited to 'repeat.go')
-rw-r--r--repeat.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/repeat.go b/repeat.go
index c7a1468..c541193 100644
--- a/repeat.go
+++ b/repeat.go
@@ -1,9 +1,7 @@
package main
+import "strings"
+
func Repeat(character string, times int) string {
- var repeated string
- for i := 0; i < times; i++ {
- repeated += character
- }
- return repeated
+ return strings.Repeat(character, times)
}