--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.com.
`range s` works differently for string and []byte. In the former case it iterates over utf8-encoded unicode codepoints, in the latter it iterates over bytes.
On Friday, November 12, 2021 at 11:10:17 PM UTC+8 axel.wa...@googlemail.com wrote:`range s` works differently for string and []byte. In the former case it iterates over utf8-encoded unicode codepoints, in the latter it iterates over bytes.It is true, but why it matters here?
--func Bar[T []byte|string](s T) bool {
for _, v := range s { // cannot range over s (variable of type T constrained by []byte|string) (T has no structural type)
if v > 100 {
return true
}
}
return false
}The message is quite confusing.--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.com.
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/abd83194-8198-40e8-ad12-82953f85fba5n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/42054eee-a9df-40d1-b148-4e5ead89ee0cn%40googlegroups.com.
Oh, sorry, I just re-read. Your example still requires `range` to return distinct types, so that probably shouldn't work.
On Nov 12, 2021, at 10:37 AM, 'Axel Wagner' via golang-nuts <golan...@googlegroups.com> wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfHFJavSL%3DtrB8ZJgXRmyzqm3PE1ae139RLy1KkkCKkRDQ%40mail.gmail.com.