[chuck-users] returning arrays from functions

eduard aylon eduard.aylon at gmail.com
Sat Oct 13 21:50:18 EDT 2007


Yes, you are right it does work. Don't know why I was getting empty  
arrays...

Thanks Cesare,

Eduard


On Oct 14, 2007, at 12:04 AM, Cesare Marilungo wrote:

> 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
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



More information about the chuck-users mailing list