Re: Gotcha with const std.range.chunks

2020-07-31 Thread sportsracer via Digitalmars-d-learn
Right, thank you! The range object needs to be mutated to be iterated on, that explains it. Although it looks like the opIndex on this particular range could guarantee constness: https://github.com/dlang/phobos/blob/v2.093.0/std/range/package.d#L8099 Here's a longer code snippet that gives s

Re: Gotcha with const std.range.chunks

2020-07-30 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jul 30, 2020 at 06:52:42PM +, sportsracer via Digitalmars-d-learn wrote: [...] > int[] xs = new int[100]; > const chunked = xs.chunks(10); > writeln(chunked[0][0]); > } > > Error: mutable method std.range.Chunks!(int[]).Chunks.opIndex is not > callable using a const object