On 2018-01-15 14:55, Nordlöw wrote:
Why do I get errors like

template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key)

for

     x.remove!(_ => _ == 1);

but not for

     x.remove!"a == 11";

?

How are these two lambdas different?

The function `remove` is a templated member of a struct instance `x`.

The difference is that the string version would not capture the surrounding context while the lambda version does. It's something related to that the lambda needs to capture both the this object, since "remove" is member of a struct, and capturing the local context of where "remove" is called. A lambda/delegate can only have one context pointer. There's an issue already reported for this.

--
/Jacob Carlborg

Reply via email to