collection/stack.go
Alexander Kiryukhin 9cd6b0fca8
initial
2022-04-07 21:36:40 +03:00

13 lines
283 B
Go

package collection
func Push[T any](collection []T, element T) []T {
return append(collection, element)
}
func Pop[T any](collection []T) ([]T, T) {
if len(collection) == 0 {
return collection, *new(T)
}
return collection[:len(collection)-1], collection[len(collection)-1]
}