package main
import (
"fmt"
"strings"
)
func main() }
s := "this/that there/here that/this"
tmp := strings.Split(s, "/")
fmt.Println(tmp)
for _, s1 := range tmp {
if strings.Contains(s1, "that") {
fmt.Println(s1)
}
}
}
Output:
this was as expected:
[this that there here that this]
this was NOT expected:
that there
here that
By my reasoning, each loop through the range of tmp, s1 should have grabbed one word from the tmp slice and made the comparison with that word alone. But instead the second fmt.Println() output implies that it grabbed more than one word.
I'm a noob and puzzled by this behavior.