From e21c9a5dc0bd49aa05ad4535efa4c8e39eaa5dee Mon Sep 17 00:00:00 2001 From: "H. S. Teoh" Date: Mon, 20 Jul 2015 11:32:18 -0700 Subject: [PATCH] Improve Lockstep docs. Remove stray // from generated docs. Reorder that example to flow better with the preceding prose. Fix coding style in code examples. --- std/range/package.d | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/std/range/package.d b/std/range/package.d index b641de2ec30..cf08580d8bf 100644 --- a/std/range/package.d +++ b/std/range/package.d @@ -3968,17 +3968,17 @@ private string lockstepMixin(Ranges...)(bool withIndex) By default $(D StoppingPolicy) is set to $(D StoppingPolicy.shortest). - BUGS: If a range does not offer lvalue access, but $(D ref) is used in the - $(D foreach) loop, it will be silently accepted but any modifications - to the variable will not be propagated to the underlying range. - - // Lockstep also supports iterating with an index variable: - Example: + Lockstep also supports iterating with an index variable: ------- - foreach(index, a, b; lockstep(arr1, arr2)) { + foreach (index, a, b; lockstep(arr1, arr2)) + { writefln("Index %s: a = %s, b = %s", index, a, b); } ------- + + BUGS: If a range does not offer lvalue access, but $(D ref) is used in the + $(D foreach) loop, it will be silently accepted but any modifications + to the variable will not be propagated to the underlying range. */ struct Lockstep(Ranges...) if (Ranges.length > 1 && allSatisfy!(isInputRange, Ranges)) @@ -4031,7 +4031,7 @@ unittest auto arr1 = [1,2,3,4,5]; auto arr2 = [6,7,8,9,10]; - foreach(ref a, ref b; lockstep(arr1, arr2)) + foreach (ref a, ref b; lockstep(arr1, arr2)) { a += b; }