<div dir="ltr">Thanks Mike. This worked.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 3, 2014 at 12:22 PM, Wilde, Michael J. <span dir="ltr"><<a href="mailto:wilde@mcs.anl.gov" target="_blank">wilde@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-size:10pt;font-family:Tahoma"><div class="im">The following following should declare an array with no elements:
<div><br>
</div>
<div>  string args[];</div>
<div><br>
</div>
</div><div><div class="im">
<div>
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div>- Mike </div>
<div>--</div>
<div>Michael Wilde</div>
<div>Mathematics and Computer Science          Computation Institute</div>
<div>Argonne National Laboratory                    The University of Chicago</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div><div style="font-size:16px;font-family:Times New Roman"><div class="im">
<hr>
<div style="direction:ltr"><font face="Tahoma" color="#000000"><b>From:</b> <a href="mailto:swift-user-bounces@ci.uchicago.edu" target="_blank">swift-user-bounces@ci.uchicago.edu</a> [<a href="mailto:swift-user-bounces@ci.uchicago.edu" target="_blank">swift-user-bounces@ci.uchicago.edu</a>] on behalf of Ketan Maheshwari [<a href="mailto:ketan@mcs.anl.gov" target="_blank">ketan@mcs.anl.gov</a>]<br>

<b>Sent:</b> Monday, February 03, 2014 11:44 AM<br>
<b>To:</b> Swift User<br>
<b>Subject:</b> [Swift-user] empty array in Swift<br>
</font><br>
</div>
<div></div>
</div><div><div class="h5"><div>
<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>
</div>
</div></div></div>
</div>
</div>
</div>

<br>_______________________________________________<br>
Swift-user mailing list<br>
<a href="mailto:Swift-user@ci.uchicago.edu">Swift-user@ci.uchicago.edu</a><br>
<a href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user" target="_blank">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user</a><br></blockquote></div><br></div>