[Closed] Freaky Array issue? Or my error?
Ok i getting bizzare issues with max tonight
i have problems with bitarrays it seems
i have say an bitarray
mybitarray #{1,2,3}
for example
now if i go
mybitarray[1] i get “false” instead of the value 1 or #{1}(which ever its supposed to output)
Is this something im doing? Am i expecting it to behave other than it should?
Bronson,
You need to use arrays to access elements. As in arr = #(); arr[1]
You can also use this method for bitArrays, but it will only return whether there is an element there or not, true if selected.
Light
Indeed an bitarray is very different to an array.
Usually, you do not need to know the value of the elements which are “false”.
Then you can use a loop like this :
mybitarray=#{2..5,7,9..10,24}
for currentValue in mybitarray do format "%
" currentValue
And you will know the value of the elements which are true (but not the others)
It is the normal usage of an bitarray…
Ok thanks guys clears things up a bit more.
Was wondering what the difrence between an array and a bitarray was. Now i know i should be able to get it right.
Thanks