This program errors out, when I try to pass lambdas that take arguments. How am I getting the syntax wrong here? Is there some reason you can't do this?

import std.stdio;

void foo(Callable)(Callable bar) {
  bar();
}

void foo2(Callable)(Callable bar, int baz) {
  bar(baz);
}

void main() {
  foo({
          writeln("okay");
        });
  foo2((bar) {
          writeln("got",bar);
        },42);
  foo2((bar) => writeln("yay",bar), 42);
}


Reply via email to