byLine

Returns an input range consisting of each line in the input argument

byLine
(
Range
)
(
auto ref Range range
)
if (
isInputRange!Range &&
isSomeChar!(ElementType!Range)
)

Examples

1 auto text = "aw\r\nyess";
2 auto range = text.byLine;
3 assert(range.front == "aw");
4 range.popFront;
5 assert(range.front == "yess");
6 auto nums = "0\n1\n2\n3\n4\n5\n6\n7\n8\n9";
7 import std.algorithm.iteration: reduce;
8 assert(nums.byLine.reduce!((a,b) => a ~ b) == "0123456789");

Meta