#Help with annonymous functions (lambda)
1 messages · Page 1 of 1 (latest)
1 messages · Page 1 of 1 (latest)
Hey there, i come from a c++/c# background for context
i want to do something like this :
foo2 = () => foo(bar); in c#
or
foo2 = bar{foo(bar);}; in c++
can you help me ? thank you
Zig doesn't have closures so not really but
You can do something like
const foo2 = struct {
bar: T,
pub fn f(self: *const @This()) void {
foo(self.bar);
}
};
// then use by passing an instance of foo2 to something which calls f
hm