References
Monkey Forums/Monkey Programming/References
| ||
As far as I understand, Monkey does not support pointers. But is it possible to send arguments by reference? For example, is it possible to port the following BlitzMax code to Monkey? Function ReturnMultiplevalues(a:Int Var,b:Int Var,c:Int Var) a=10 b=20 c=30 Return End Function Function PrintNumbers() Local x:Int, y:Int, z:Int ReturnMultipleValues(x,y,z) Print "x="+x '10 Print "y="+y '20 Print "z="+z '30 End Function |
| ||
No, it's not possible. |
| ||
But you can box values. So not really a "serious" issue. |
| ||
Hi ziggy, what is this "box values" thingymijingy? |
| ||
Ah, cool! Thanks a lot! @MikeHart You can use arrays. Here's how I did it: Function ReturnMultiplevalues(a:int[]) a[0] = 10 a[1] = 20 a[2] = 30 End Function PrintNumbers() Local arr:int[3] ReturnMultiplevalues(arr) Print arr[0] + ", " + arr[1] + ", " + arr[2] End |
| ||
Using arrays is a way of boxing. The other whould be using a class that acts like an Int container. That's boxing. |
| ||
Thanks for the valuable info. Much appreciated. |