Thread overview | |||||
---|---|---|---|---|---|
|
December 08, 2018 ElementType of MapResult is a delegate?? | ||||
---|---|---|---|---|
| ||||
This surprised me A LOT: https://d.godbolt.org/z/82a_GZ So if I call something.map!().array, I get an array of delegates? That makes no sense to me. |
December 08, 2018 Re: ElementType of MapResult is a delegate?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuxuan Shui | On Saturday, 8 December 2018 at 13:02:00 UTC, Yuxuan Shui wrote:
> This surprised me A LOT:
>
> https://d.godbolt.org/z/82a_GZ
>
> So if I call something.map!().array, I get an array of delegates? That makes no sense to me.
But in your example, "(a) =>" returns "{return tmp;}", which is a delegate. Just write "(a) => tmp", or invoke the delegate by turning it into a call: "{return tmp;}()".
|
December 09, 2018 Re: ElementType of MapResult is a delegate?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Chapman | On 12/8/18 8:19 AM, John Chapman wrote:
> On Saturday, 8 December 2018 at 13:02:00 UTC, Yuxuan Shui wrote:
>> This surprised me A LOT:
>>
>> https://d.godbolt.org/z/82a_GZ
>>
>> So if I call something.map!().array, I get an array of delegates? That makes no sense to me.
>
> But in your example, "(a) =>" returns "{return tmp;}", which is a delegate. Just write "(a) => tmp", or invoke the delegate by turning it into a call: "{return tmp;}()".
This is exactly why (a) => {return tmp;} should not compile.
Almost everyone has made that mistake.
-Steve
|
Copyright © 1999-2021 by the D Language Foundation