Skip to content

proposal: x/exp/slices: add Pop #52434

Closed
Closed
@thatradius

Description

@thatradius
// Pop removes the elements s[i] from s, returning the modified slice
// and the removed element. Pop panics if s[i] is not a valid slice of s.
func Pop[S ~[]E, E any](s S, i int) (S, E) {
	e := s[i]
	return append(s[:i], s[i+1:]...), e
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions