Best way to return an array position from a funct
BlitzMax Forums/BlitzMax Beginners Area/Best way to return an array position from a funct
| ||
Hello, Recently I've begun work on a function that needs to evaluate an array and return a position in that array. What is the best way to do this? I can write an object that acts as a sort of wrapper for the return x and y. I'm also thinking that there may be a way to do this with a pointer. I really haven't studied pointers much though so I may be off base. Also it seems that there would be overhead in using a array position object. I need a function that evaluates a 2d array and returns a position in that 2d array. I would rather not write a position wrapper object unless it would be faster |
| ||
Hi Ryan You could use Var to return the position... Local x:Int, y:Int arraythingy(x,y) Print x+", "+y Function arraythingy(x:Int Var,y:Int Var) x=2 ; y=3 EndFunction or even an array... Local pos:Int[] = arraythingy() Print pos[0]+", "+pos[1] Function arraythingy:Int[]() Return [2,3] EndFunction |