On Sunday, 12 July 2015 at 17:33:50 UTC, anonymous wrote:
On Sunday, 12 July 2015 at 17:25:17 UTC, Gary Willoughby wrote:
Why does the following code fail to compile if the `writeln(value);` line is present?

The error message (formatted to be a little more readable):
----
Error: function test2.__unittestL6_1.Foo.opApply
  (int delegate(ref string) nothrow dg)
is not callable using argument types
  (int delegate(ref string __applyArg0) @system)
----

Note that the parameter has "nothrow", but the argument doesn't. And that's it: writeln isn't nothrow.

Ah right, because the body of the foreach becomes the body of the delegate. Thanks.

Reply via email to