Re: Empty functions

2020-10-29 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 29, 2020 at 09:06:21AM +, Jan Hönig via Digitalmars-d-learn wrote: > On Thursday, 29 October 2020 at 09:01:12 UTC, Jan Hönig wrote: > > This would mean, that this one should work as well. > > It does not work as I intended, as `() => {}` has not the return type > of `void`. > >

Re: Empty functions

2020-10-29 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 29 October 2020 at 09:06:21 UTC, Jan Hönig wrote: On Thursday, 29 October 2020 at 09:01:12 UTC, Jan Hönig wrote: This would mean, that this one should work as well. It does not work as I intended, as `() => {}` has not the return type of `void`. (I don't know how to print:

Re: Empty functions

2020-10-29 Thread rikki cattermole via Digitalmars-d-learn
On 29/10/2020 10:06 PM, Jan Hönig wrote: On Thursday, 29 October 2020 at 09:01:12 UTC, Jan Hönig wrote: This would mean, that this one should work as well. It does not work as I intended, as `() => {}` has not the return type of `void`. (I don't know how to print: `ReturnType!(() => {})`)

Re: Empty functions

2020-10-29 Thread Jan Hönig via Digitalmars-d-learn
On Thursday, 29 October 2020 at 09:01:12 UTC, Jan Hönig wrote: This would mean, that this one should work as well. It does not work as I intended, as `() => {}` has not the return type of `void`. (I don't know how to print: `ReturnType!(() => {})`)

Re: Empty functions

2020-10-29 Thread Jan Hönig via Digitalmars-d-learn
On Thursday, 29 October 2020 at 08:48:59 UTC, rikki cattermole wrote: () => {} Is actually: () => Expression Rule: ref|opt ParameterWithMemberAttributes => AssignExpression https://dlang.org/spec/expression.html#lambdas This would mean, that this one should work as well. And you can![1] I

Re: Empty functions

2020-10-29 Thread rikki cattermole via Digitalmars-d-learn
(Params){ FunctionBody; } Rule: ref|opt ParameterWithMemberAttributes FunctionLiteralBody https://dlang.org/spec/expression.html#function_literals void function() Is a type https://dlang.org/spec/type.html#delegates () => {} Is actually: () => Expression Rule: ref|opt