Comment

Comment by millstone

Disagree hard!

    a = append(a[:i], a[i+1:]...)
That’s the recommended implementation of erase(). After this, is the original object referred to by ‘a’ modified? How can you tell?

Let’s pop from a stack:

    x, a = a[len(a)-1], a[:len(a)-1]

Did you read that 100x faster than ‘a.pop()’?

Now this:

    a = append(a[:i], append(make([]T, j), a[i:]...)...)
This is an operation called “expand.” What does it do? It is an honest question, I have no idea.

These are completely idiomatic examples taken from the Go wiki. They are not readable.

parent millstone 7 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton