-
-
Notifications
You must be signed in to change notification settings - Fork 749
Open
Description
The compound format has two forms: %(…%) and %(…%|…%), the latter allowing to specify the delimiter precisely. However, rather commonly, the delimiter must be different for the last pair of elements. Let’s allow for 2 or 3 delimiters to handle the last pair, i.e. %(…%|d₀%|d₁%) and %(…%|d₀%|d₁%|d₂%) such that d₀ is used between all elements but the last pair. For the last pair, use d₂ if it’s the only pair, otherwise use d₁. If d₂ isn’t given, it’s as if it were identical to d₁.
Example:
foreach (friends; [["John", "Nancy"], ["Amy", "Joe", "Taylor"]])
{
writefln("My friends are %-(%s%|, %).", friends);
// My friends are John, Nancy.
// My friends are Amy, Joe, Taylor.
writefln("My friends are %-(%s%| and %).", friends);
// My friends are John and Nancy.
// My friends are Amy and Joe and Taylor.
// Proposed: Two %|
writefln("My friends are %-(%s%|, %| and %).", friends);
// My friends are John and Nancy.
// My friends are Amy, Joe and Taylor.
// Proposed: Three %|
writefln("My friends are %-(%s%|, %|, and %| and %).", friends);
// My friends are John and Nancy.
// My friends are Amy, Joe, and Taylor.
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels