New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slice - add function to delete item #43185
Comments
Operation on slices should be simple as for map |
@PawelPru the thing is, removal from a map has O(1) complexity whereas removing from a slice has O(n) complexity. If we made removals from both maps and slices look the same, we’d obscure from programmers the very different costs those operations have. |
@davecheney anyhow if you want to remove item from slice you need to make additional operations. Right now such function dosn't exist and instead of simplicity we have complexity. Trick with slices may help but should be build-in |
@PawelPru i don’t disagree, I just wanted to raise this point as this is part of Go’s general implicit policy of not hiding the cost of operations behind magic. I encourage you to search the issue tracker for previous discussions in this area as there have been many. |
I agree with @davecheney . I'll add that this is something to be solved with generics, not with a change to the language. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Trying to remove first item
import "fmt"
func main() {
}
What did you see instead?
error
The text was updated successfully, but these errors were encountered: