• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] takes integer array

Status
Not open for further replies.
Level 16
Joined
Oct 12, 2008
Messages
1,570
Hello people,,

I have heard about a function taking an array is impossible,,
But with some new type, it would be,
Now how would i properly use it? I have got type integerarray extends integer array [10]

How can i convert an 'integer array' to an 'integerarray' ? And vice versa.

Or is this not possible?

Thanks

-Yixx,,-
 
Level 6
Joined
Oct 4, 2008
Messages
263
however, you could create a struct type with an integer array member.

JASS:
struct intarray
integer array[XYZ] i
endstruct
 
An example:

JASS:
type intarr extends integer array [10] // create a dynamic array with a maximum of 10 array slots

function GetArrayIndex takes intarr arr, integer i returns integer
    return intarr[i]
endfunction
As you should be able to see from that, dynamic arrays behave exactly the same as normal arrays except they have a limit (the number in brackets when you declare it). Oh, and they have to be created like structs before you can use them. Like this:
JASS:
local intarr arr = intarr.create() //create an instance of intarr
//do stuff
 
Status
Not open for further replies.
Top