[chuck-users] returning arrays from functions
Cesare Marilungo
cesare at poeticstudios.com
Sat Oct 13 18:04:27 EDT 2007
eduard aylon wrote:
> This seems something I should have done in the past, but I can't
> figure out how to return an array from a function. Couldn't find
> documentation nor examples.
>
> case 1: compiling error. This seems the more natural way to me.
>
> fun int return_array( int a[] )
> {
> return a;
> }
>
> case 2: works, but the returned array is empty
>
> fun int[] return_array( int a[] )
> {
> return a;
> }
>
Hi,
case 2 works here:
[ 1,2,3 ] @=> int anarray[];
fun int[] return_array( int a[] )
{
return a;
}
<<< return_array( anarray )[0] >>>; //prints: 1: (int)
>
> thanks,
>
> eduard
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>
>
--
www.cesaremarilungo.com
More information about the chuck-users
mailing list