More importantly, this will take me a minute to read and two minutes to make sure it’s doing the right thing every time I encounter it somewhere new.
I don’t think I will ever understand why so many go advocates seem so openly hostile to encapsulation. If go had used C-style for loops, I swear there would be people here defending the decision saying:
sum := 0
for (i := 0; i <= len(a); i++) {
sum = sum + a[1]
}
“See? Only four lines. What’s the big deal? It took me literally thirty seconds to write.”
Is that an O(n) implementation of pop? I hope you realize my point..
I looked it up and it's not but the point is that you shouldn't have to worry about these things, including implementation details of trees and hundreds of other data structures.