On Tuesday, 17 November 2015 at 23:22:58 UTC, Brad Anderson wrote:
One solution: [snip]
Thanks for the quick response. Extending your example, here's another style that works and may be nicer in some cases.
import std.stdio; import std.range; import std.algorithm; void main(string[] args) { auto x1 = ["abc", "def", "ghi"]; auto x2 = ["jkl", "mno", "pqr"]; auto x3 = ["stu", "vwx", "yz"]; auto y1 = (args.length > 1) ? x1 : []; auto y2 = (args.length > 2) ? x2 : []; auto y3 = (args.length > 3) ? x3 : []; chain(y1, y2, y3).joiner(", ").writeln; }