Loop array using while loop and array length
a = [1, "test", 2, 3, 4] i = 0 # w w w . ja va 2 s .com while (i < a.length) puts a[i].to_s + "X" i += 1 end