Passing foo function’s “…” or array parameter to foo2 gives a compile error: “cannot use p (variable of type []int) as int value in argument to foo2”
Is there a way to work around this?
The code:
func foo(p ...int) {
foo2(p)
}
func foo2(p2... int) {
//some code
}
I’m working on a project in which I wanted to create a function similar to this problem to refactor some code.
New contributor
poprundelhd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.