float init 0 request

Walter Bright newshound2 at digitalmars.com
Tue Aug 25 07:04:01 UTC 2026


On 8/21/2026 1:54 PM, Mindy Batek (0xEAB) wrote:

> ```d
> int foo() const
> {
>      for (auto next = this.next; next !is null; next = next.next) // Error: 
> cannot modify `const` expression `next`
>      {
> ```

Replace `auto` with `const(List)*` and you're good to go!

```d
struct List { List* next; }

struct S
{
     List* next;

     void foo() const
     {
         for (const(List)* next = this.next; next !is null; next = next.next) { }
     }
}
```



More information about the Digitalmars-d mailing list