the values to assemble together
A RandomAccessRange of the assembled values.
1 import std.algorithm.comparison : equal; 2 import std.algorithm.iteration : filter, joiner, map; 3 import std.algorithm.searching : findSplitBefore; 4 import std.uni : isUpper; 5 6 assert(equal(only('♡'), "♡")); 7 assert([1, 2, 3, 4].findSplitBefore(only(3))[0] == [1, 2]); 8 9 assert(only("one", "two", "three").joiner(" ").equal("one two three")); 10 11 string title = "The D Programming Language"; 12 assert(title 13 .filter!isUpper // take the upper case letters 14 .map!only // make each letter its own range 15 .joiner(".") // join the ranges together lazily 16 .equal("T.D.P.L"));
chain to chain ranges
Assemble values into a range that carries all its elements in-situ.
Useful when a single value or multiple disconnected values must be passed to an algorithm expecting a range, without having to perform dynamic memory allocation.
As copying the range means copying all elements, it can be safely returned from functions. For the same reason, copying the returned range may be expensive for a large number of arguments.