byChunk odd behavior?

Chris Wright via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 23 11:56:58 PDT 2016


On Wed, 23 Mar 2016 03:17:05 +0000, Hanh wrote:
> In Scala, 'take' consumes bytes from the iterator. So the same code
> would be buffer = range.take(N).toArray

import std.range, std.array;
auto bytes = byteRange.takeExactly(N).array;

There's also take(N), but if the range contains fewer than N elements, it 
will only give you as many as the range contains. If If you're trying to 
deserialize something, takeExactly is probably better.


http://dpldocs.info/experimental-docs/std.range.takeExactly.html
http://dpldocs.info/experimental-docs/std.array.array.1.html


More information about the Digitalmars-d-learn mailing list