• 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.

switch function in jass?

Status
Not open for further replies.
Level 2
Joined
Jun 15, 2013
Messages
10
hiho

i decided to write my itemdropp functions in jass and now i'm wondering:
is there a function like switch in other languages?
or do i have to make a long chain of elseif functions?

thank you^^
 
Long chain of elseif statements as a last resort.

If you can use an array for this, go for it. It depends on the kind of information you have.

Beware though: Arrays have a size of 8192 at most (They are allocated dynamically in a logarithmic fashion)

If arrays won't cut it, use a hashtable.

You might be able to use an array even if your integers exceed 8192 by subtracting something like 'I000' for item ids (assuming you're going with the default raw codes generated by the Object Editor).

For unit raw codes, it gets a bit more complicated, so I'd suggest just using a simple hashtable in that case.
 
Status
Not open for further replies.
Top