r. The exact effect is dependent upon the two
types. Several cases are accepted, as described below. The code snippets
are attempted in order, and the first to compile "wins" and gets
void put(R, E) (
ref R r,
When an output range's
put method only accepts elements of type
T, use the global
put to handle outputting a
T to the range
put treats dynamic arrays as array slices, and will call
on the slice after an element has been copied.
Be sure to save the position of the array before calling
int a = [1, 2, 3], b = [10, 20]; auto c = a; put(a, b); writeln(c); // [10, 20, 3] // at this point, a was advanced twice, so it only contains // its last element while c represents the whole array writeln(a); // 
It's also possible to
put any width strings or characters into narrow
strings -- put does the conversion for you.
Note that putting the same width character as the target buffer type is
nothrow, but transcoding can throw a
// the elements must be mutable, so using string or const(char) // won't compile char s1 = new char; auto r1 = s1; put(r1, "Hello, World!"w); writeln(s1); // "Hello, World!"