* Kurtis Rader <kra...@skepticism.us> [190807 18:43]:
> Please don't respond to threads that are seven years old. Having said that
> the behavior is reasonable and the behavior you and the O.P. expect is not
> reasonable. Consider the following examples:
> 
> result := strings.Split("abc", "")
> result := strings.Split("ab", "b")
> result := strings.Split("", "")
> 
> The first statement yields a slice of three elements. The second a slice of
> two elements with the second being an empty string. What should the second
> statement yield? A slice of one element (the empty string) or an empty
> slice? The former is consistent with all the other cases while the latter
> is inconsistent.

You are mixing apples and oranges.  The rule is different if the
separator is "" than if it is not empty.  This playground link
https://play.golang.org/p/6nbTIW50i2g shows the difference.  The OP was
asking about " " (non-empty) as the separator.  The documentation for
Split is very specific about both these cases.

...Marvin

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/20190808103604.pfbeaj7tg6gwwyyy%40basil.wdw.

Reply via email to