mirror of
https://github.com/Hopiu/micro.git
synced 2026-04-03 22:50:35 +00:00
Implement Spaces() with with strings.Repeat()
Shorter and more efficient.
This commit is contained in:
parent
37ad137012
commit
43eb238b08
1 changed files with 1 additions and 5 deletions
|
|
@ -36,11 +36,7 @@ func NumOccurrences(s string, c byte) int {
|
|||
|
||||
// Spaces returns a string with n spaces
|
||||
func Spaces(n int) string {
|
||||
var str string
|
||||
for i := 0; i < n; i++ {
|
||||
str += " "
|
||||
}
|
||||
return str
|
||||
return strings.Repeat(" ", n)
|
||||
}
|
||||
|
||||
// Min takes the min of two ints
|
||||
|
|
|
|||
Loading…
Reference in a new issue