array functions with type
BlitzMax Forums/BlitzMax Programming/array functions with type
| ||
what's wrong with this? I don't have a clue of why i am getting an error :s Type t Field a:Int Field b:Int End Type Function func:t[]() Local test:t[]=New t[2] test[0].a=1 Return test End Function Local x:t[]=func() Error returned while executing : Unhandled Exception: Attempt to access field or method of Null object (highlightened line : test[0].a=1) Edit : It works fine when i don't use types Function func:Int[]() Local test:Int[]=New Int[2] test[0]=1 Return test End Function Local x:Int[]=func() |
| ||
Type t Field a:Int Field b:Int End Type Function func:t[]() Local test:t[]=New t[2] test[0] = New t test[1] = New t test[0].a=1 Return test End Function Local x:t[]=func()With types New t[2] just creates a two pointer array "test", it doesnt actualy create the two types test[0] or test[1] |