On Monday, 24 October 2022 at 21:52:18 UTC, Ali Çehreli wrote:
On 10/24/22 14:26, Per Nordlöw wrote:
[...]
Another option is to use range functions where front() returns
a Tuple. We have an esoteric feature where a tuple expands
automatically in foreach loops:
import std.typecons : tuple;
On 10/24/22 14:26, Per Nordlöw wrote:
What property of a container (type) `T` enables iteration as
```d
foreach (k, v; T.init)
{
...
}
```
? I thought it sufficed to define `T.byKeyValue` but its presence seem
to have no effect.
Another option is to use range functions where front() ret
On Mon, Oct 24, 2022 at 09:26:14PM +, Per Nordlöw via Digitalmars-d-learn
wrote:
> What property of a container (type) `T` enables iteration as
>
> ```d
> foreach (k, v; T.init)
> {
> ...
> }
> ```
>
> ? I thought it sufficed to define `T.byKeyValue` but its presence seem
> to have no ef
What property of a container (type) `T` enables iteration as
```d
foreach (k, v; T.init)
{
...
}
```
? I thought it sufficed to define `T.byKeyValue` but its presence
seem to have no effect.
From there down:
https://dlang.org/spec/statement.html#foreach_over_struct_and_classes