How do I put a vector inside of a struct in Go?
Posted
by Brian T Hannan
on Stack Overflow
See other posts from Stack Overflow
or by Brian T Hannan
Published on 2009-11-23T03:59:24Z
Indexed on
2010/03/19
16:21 UTC
Read the original article
Hit count: 195
I'm trying to put a vector variable inside a struct in Google's Go programming language. This is what I have so far:
Want:
type Point struct { x, y int }
type myStruct struct {
myVectorInsideStruct vector;
}
func main(){
myMyStruct := myStruct{vector.New(0)};
myPoint := Point{2,3};
myMyStruct.myVectorInsideStruct.Push(myPoint);
}
Have:
type Point struct { x, y int }
func main(){
myVector := vector.New(0);
myPoint := Point{2,3};
myVector.Push(myPoint);
}
I can get the vector to work in my main function just fine, but I want to encapsulate it inside a struct for easier use.
© Stack Overflow or respective owner