How do folks write anonymous functions in Zig?
I wrote the following this zls seemed to not display any errors.
root.visitDirs(fn (n: *Node) void {
if (n.typ == .dir) {
print("{s}: {d}", .{ n.name, n.totalSize() });
}
});
But when I run it, I see this:
main.zig:56:13: error: use of undeclared identifier 'n'
if (n.typ == .dir) {
n is clearly defined in the parameter list of the function, so I'm guessing I'm writing anonymous functions incorrectly.
I forgot about it. Ugh.