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.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to