Re: evenChunks on a string - hasLength constraint fails?

2023-03-16 Thread amarillion via Digitalmars-d-learn
On Tuesday, 14 March 2023 at 18:41:50 UTC, Paul Backus wrote: On Tuesday, 14 March 2023 at 08:21:00 UTC, amarillion wrote: I'm trying to understand why this doesn't work. I don't really understand the error. If I interpret this correctly, it's missing a length attribute on a string, but shouldn

evenChunks on a string - hasLength constraint fails?

2023-03-14 Thread amarillion via Digitalmars-d-learn
Hey I'm trying to split a string down the middle. I thought the function std.range.evenChunks would be perfect for this: ``` #!/usr/bin/env -S rdmd -I.. import std.range; void main() { string line = "abcdef"; auto parts = evenChunks(line, 2); assert(parts == ["abc", "