how is this array subtyping inside struct (bug?) possible?

RazvanN razvan.nitu1305 at
Mon Aug 10 02:38:55 UTC 2020

On Sunday, 9 August 2020 at 21:12:58 UTC, mw wrote:

> I'm *directly* access the underlying array, so why its length 
> changed to 0 after writeln?
You are accessing the underlying array after it was consumed. The 
line writeln(s0.fns) passes class, if you want to pass the 
underlying array you should type `writeln(so.fns.array)` and then 
it will not consume the array.

> So a plain array *is* also a range? I've thought (an array's) 
> range is a *separate* struct (which wrap the original array). 
> The wrapper range can be consumed, but the underlying array 
> should stay the same.
> I never seen it's mentioned in the doc:

You had a type in your code.

More information about the Digitalmars-d mailing list