damn, Golang is picky! https://octodon.social/media/rPvteRvL9otauckN9fk
man idk, Rust is putting up way more of a fight than Golang did for me... I guess that's kind of by design though. https://octodon.social/media/yjYuGa_nH0PH-WbDscA
Alright I got tic-tac-toe working in both Go and (omg the struggle) Rust!
Here's my long blog post about it: https://sts10.github.io/2017/11/18/trying-go-and-rust.html (tl;dr Rust seems like a really cool idea, but Go seems more practical for most)
Golang repo: https://github.com/sts10/tic-tac-go
Rust repo: https://github.com/sts10/rusty-tac
@Clipsey ah, I feel like that'll be the next thing for me to investigate (that or interfaces).
So this function is named "Add", the input is "other" of type Vector, and... there's no output?
@schlink https://github.com/Member1221/mgj2017 Here's a small game i made in golang for a game jam, tried to make golang be quite OOP with interfaces, feel free to poke around with the code :D
@Clipsey gotcha, think that makes sense.
@schlink also, you found a mistake in the code, there should be a return of Vector in the end
@Clipsey ha!
Tell me more about that asterisk though-- `(v *Vector)`. Is that a pointer to your defined type Vector? Why do you need as an asterisk there and I never needed one in my code? What's it called in the docs?
@schlink The asterisk, is indeed a pointer, as i prefer passing around references, also allows you to return nil on errors, and such.
@schlink
func (v *Vector) Add(other Vector) *Vector {
return &Vector{v.X + other.X, v.Y + other.Y}
}
@schlink Fixed version i think idk im too tired
@Clipsey ok, guess I'll have to think of a project where I'll need structs with functions!
@schlink nifty thing with pointers aswell, the inbuilt function new.
pos := new(Vector)
Will return a pointer to vector with default data. (X = 0, Y = 0) as far as i remember.
@schlink You need structs before interfaces can be useful, unless you use interface{}, which is golang's form of OOP object class.