On Jun 25, 2006, at 17:50, Dark Ambient wrote:

> Is there a way to set the indice on an array,
> i.e.
>
> Instead of:
>
> myarray = [1,2,3,4,5]
> myarray[1] =2
> myarray[4]=5
>
> myarray[A]=1
>
> I know this can be done using hashes but was not sure with arrays

Negate that last answer - I misunderstood.  Sorry.

Anyway, array indices are always integers.  As long as A references  
or evaluates to an integer, no problem:

A = 3
myarray = []
myarray[A] = "foo"
=> [nil, nil, nil, "foo"]

matthew smillie.