How to convert a piece of string to a rune slice
1 answer
I would rather not use it strings.Join(array,"")
for this purpose because it creates one big newline which I don't need. Making a large string that I don't need is not cost effective, and depending on input and hardware, it can be time inefficient.
So, instead, I'll loop through the array of string values ββand convert each string to a rune slice and use the built-in variational addition function to grow my slice of all rune values:
var allRunes []rune
for _, str := range array {
allRunes = append(allRunes, []rune(str)...)
}
+4
source to share