ruby - How can I loop through arrays skipping previously referred elements? -
is there way loop through 2 arrays , have them refer element each time? example:
first_array = ['a', 'b', 'c', 'd'] second_array = ['e', 'f', 'g', 'h'] first_array.each |item| puts item.get(second_array)
the results like:
a work e b work f c work g d work h
i'm trying make when variable first_array
passed work second_array
, moves next variable in second_array
, skipping used variable.
that zip
.
first_array.zip(second_array){|e1, e2| ...}
Comments
Post a Comment