David,<div><br></div><div>I think the problem may be that you are returning an array that is local to your function and it is getting deallocated when the function returns.</div><div><br></div><div>If you used the same syntax to instead return an object's member variable which is an array, I think it would work as expected.</div>

<div><br></div><div>Hope that helps.</div><div>----------<div>Colin<br></div><br>
<br><br><div class="gmail_quote">2012/2/23 David Ogborn <span dir="ltr"><<a href="mailto:ogbornd@mcmaster.ca">ogbornd@mcmaster.ca</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word">Hi Chuckists,<div><br></div><div>A question about arrays in Chuck: the manual briefly mentions "functions that have arrays as arguments or return type" but I can't seem to find an actual example of a function with an array as a return type.  Does anyone know if this works, or there is a way to make it work?</div>

<div><br></div><div>If I call the function below, for instance, I get a "NullPointerException: (array access)" when I do anything with the result:</div><div><br></div><div>fun float[] t(float x,float nn[]) {<br>

    float rr[];<br>    for(0 => int n;n<nn.size();n++) {<br>        nn[n] + x => rr[n];<br>    }<br>    return rr;<br>}</div><div><br></div><div>Yours truly,</div><div>David</div><div><br><div>
<div style="word-wrap:break-word"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<div><div><div>-------------------------------------------------------------------</div><div>Dr. David Ogborn, Assistant Professor<br>Communication Studies & Multimedia</div><div>Director, Cybernetic Orchestra & ESP Studio</div>

<div>McMaster University, Hamilton, Canada<br><br>ogbornd --at-- <a href="http://mcmaster.ca" target="_blank">mcmaster.ca</a></div><div><div><a href="http://davidogborn.net/" target="_blank">http://davidogborn.net</a></div>

<div><a href="http://twitter.com/ogbornd" target="_blank">http://twitter.com/ogbornd</a></div><div><span style="font-size:medium"><a href="http://esp.mcmaster.ca/" target="_blank">http://esp.mcmaster.ca</a> (Cybernetic Orchestra)</span></div>

</div><div><a href="tel:1-905-525-9140%20ext%2027603" value="+19055259140" target="_blank">1-905-525-9140 ext 27603</a></div></div><div><br></div></div></div></span><br></div></span><br></div><br><br>
</div>
<br></div></div><br>_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
<br></blockquote></div><br></div>