`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 Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com <tapir....@gmail.com>
wrote:

>
> 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+unsubscr...@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
> <https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEkBMfHKr4m3sAsuCVG0_-AZniF1vDyWU1Umoi3sO1Jujq1ZTA%40mail.gmail.com.

Reply via email to