On Wed, Dec 25, 2019 at 8:05 PM Gert <
gert.c...@gmail.com> wrote:
>
> Is there a cleaner way to write the
>
> s:= *t
> *t = s[i+1:]
>
> part?
>
> was hoping for something like *t = *t[i+1:]
Indexing comes before indirection, so use parens:
*t=(*t)[i+1:]
>
>
> type Token []byte
>
> func (t *Token) Next() bool {
> if i := bytes.IndexByte(*t, '.'); i > -1 {
> s := *t
> *t = s[i+1:]
> return true
> }
> return false
> }
>
> func (t Token) String() string {
> if i := bytes.IndexByte(t, '.'); i > -1 {
> return string(t[:i])
> }
> return string(t)
> }
>
> --
> 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/5f59f852-99e5-472f-9857-cac893907ad6%40googlegroups.com.