Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumGogenerics type parametersSingle-choice MCQ

Given this generic stack, what does the call to Push print and why?

type Stack[T any] struct{ items []T } func (s Stack[T]) Push(v T) { s.items = append(s.items, v) } func main() { s := Stack[int]{} s.Push(1) s.Push(2) fmt.Println(len(s.items)) }