May 15, 2013 [Issue 10087] New: std.range.chunks problem with chunkSize = 0 | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10087 Summary: std.range.chunks problem with chunkSize = 0 Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2013-05-15 09:49:44 PDT --- import std.stdio: writeln; import std.range: chunks; void main() { chunks("abcd"d, 0).writeln; } Prints an unbound range of empty strings, I think this is not good: ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" ... I suggest to refuse the chunkSize = 0 with a pre-condition (or worse with an enforce). An alternative solution is to make 0 a special case, and return the whole iterable: std.range.chunks("abcd"d, 0).writeln; ==> ["abcd"] -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation