<div dir="ltr">Hi,<div><br></div><div>I was working on a problem where user can pass a dynamic number of arguments to an app, including zero. </div><div><br></div><div>A possible Swift script as follows:</div><div><br></div>
<div><div>type file;</div><div><br></div><div>app (file _out, file _err) anapp(file _exec, int _i, string _args[]){</div><div>    sh @_exec _i _args stdout=@_out stderr=@_err;</div><div>}</div><div>string args[]=["any", "num", "args"]; # generated via a wrapper script</div>
<div><br></div><div>file exec<"./echo.sh">;</div><div>foreach i in [0:9:1]{</div><div>    file out <single_file_mapper; file=@strcat("outloc", "/", i, ".out")>;</div><div>
    file err <single_file_mapper; file=@strcat("outloc", "/", i, ".err")>;</div><div>    (out,err) = anapp(exec, i, args);</div><div>}</div></div><div><br></div><div>However, it seems that I cannot have an array with no elements:</div>
<div><br></div><div>string args[]=[];</div><div><br></div><div>In this case Swift complains:</div><div>Compile error in assignment at line 8: You cannot assign value of type [int] to a variable of type string[int]<br></div>
<div><br></div><div>Which works when I say:</div><div><br></div><div>string args[]=[""]</div><div><br></div><div>However, it results in an array with one element.</div><div><br></div><div>So, is there a way in Swift to have an array with zero elements?</div>
<div><br></div><div>Thanks,</div><div>Ketan</div></div>