Array order

● ARCHIVED · READ-ONLY
Started by Yin 6 posts View original ↗
  1. I have a piece of code that is not working as intended.

    loop for item

            num = all[m_index][2]

            num.times do

              @stuff[index] << item

            end

    end

     

    item gives me a number, not an array. It's supposed to push the item into the array num times. For some reason, it puts the items into their own arrays.

     

    It gives me

     

    [[1], [2,2,2,2], [3]]

     

    I want it to give me [1, 2, 2, 2, 2, 3]

     

    What am I doing wrong?

     

    Fixed, but I have a new array problem. I'm trying to compare the elements in one array to another. I want it so that if the contents are the same, it will be true regardless of if they are in the correct order. Is there any way to do that?
  2. You'd probably have to sort them both into temporary arrays first, and then compare the temporary arrays.
  3. Thanks :D I did that before, but it didn't work, but when I changed the array elements to numbers instead, it worked.
  4. so all sorted then?
  5. Yes, along with the other problems that I posted.
  6. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.