[RMXP] Using arrays to randomize variables

I've been wanting to make an enemy in my game, who only appears in specific rooms, and switches them at random.
My idea was to use a script call to randomize the variable with an array that features all rooms, however, I couldn't find anything about arrays for XP or other versions that use Ruby, so I'm wondering if it's even supported.
How do I use arrays in XP? And if there aren't arrays, then, is there a script or an alternative way to do this?
If you selected a sequence starting from 0, you can just pick one by calling:

rand(MAXNUMBER)

And it will always pick any of the rooms randomly if you assign its return value (result) to a game variable.
Well yeah, I do know that
But the rooms are not lined up in ID order, so this doesn't work
The same principle applies for any array.

Ruby:
room_ids = [1, 2, 3]
$game_variables[100] = rand(room_ids.size)
After a bit of messing around, I got it to work! Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/rmxp-using-arrays-to-randomize-variables.174121/