On Wednesday, 23 March 2016 at 19:07:34 UTC, cym13 wrote:

In Scala, 'take' consumes bytes from the iterator. So the same code would be
buffer = range.take(N).toArray

Then just do that!

    import std.range, std.array;
    auto buffer = range.take(N).array;

    auto example = iota(0, 200, 5).take(5).array;
    assert(example == [0, 5, 10, 15, 20]);

Well, that's what I do in the first post but you can't call it twice with an InputRange.

auto buffer1 = range.take(4).array; // ok
range.popFrontN(4); // not ok
auto buffer2 = range.take(4).array; // not ok

Reply via email to