problem description
the environmental background of the problems and what methods you have tried
Val
is a member variable of TreeNode
structure
stack.Peek ()
the return value is (bool, interface {})
related codes
_, _top := stack.Peek()
//
// _top = _top.(*TreeNode)
// res = append(res, _top.Val)
//
res = append(res, _top.(*TreeNode).Val)
//
_top2 := _top.(*TreeNode)
res = append(res, _top2.Val)
what result do you expect? What is the error message actually seen?
Why do I report an error when I first cast the type of the two lines of code that are commented out, and then go to fetch the Val? The error message is
type interface {} is interface with no methods