github.com/enetx/g@v1.0.80/examples/iter/iter_intersperse.go (about) 1 package main 2 3 import ( 4 "github.com/enetx/g" 5 ) 6 7 func main() { 8 // Example 1 9 g.Slice[string]{"Hello", "World", "!"}.Iter(). 10 Intersperse(" "). 11 Collect(). 12 Join(). 13 Print() // Hello World ! 14 15 // Example 2 16 str := g.String("I love ice cream. Ice cream is delicious.") 17 matches := g.Slice[g.String]{"Ice", "cream"}.Iter().Intersperse("").Collect().Append("") 18 19 str = str.ReplaceMulti(matches...) 20 str.Print() // I love ice . is delicious. 21 }