I'm relatively new to zig and playing around with advent of code right now.
I have a loop in which i am reading two point's per line and putting them in a list or not depending on whether they are already there, but at the end of all the lines all my points have the contents of the last line.
var points = std.ArrayList(*Point).init(allocator);
while (it.next()) |line| {
var pointA: *Point = undefined;
var pointB: *Point = undefined;
if (aExists == false) {
var point = Point{
.name = a,
};
pointA = &point;
try points.append(pointA);
}
if (bExists == false) {
var point = Point{
.name = b,
};
pointB = &point;
try points.append(pointB);
}
}
This code is obviously abridged, but i hope the issue is clear.