C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Golang program that uses Join
package main
import (
"fmt"
"strings"
)
func main() {
// Create a slice and append three strings to it.
values := []string{}
values = append(values, "cat")
values = append(values, "dog")
values = append(values, "bird")
// Join three strings into one.
result := strings.Join(values, "...")
fmt.Println(result)
}
Output
cat...dog...bird
So: No delimiter is needed. We can join with an empty string. This creates the most compact string representation possible.
Golang program that joins with no delimiter
package main
import (
"fmt"
"strings"
)
func main() {
// A slice of 3 strings.
values := []string{"a", "b", "c"}
// Join with no separator to create a compact string.
joined := strings.Join(values, "")
fmt.Println(joined)
}
Output
abc