Hi,
I'm still new to ruby on rails and web development so please bear with me:
I have two arrays a1 = [1,2,3,4] b1 = [7,6,5,4]
I want to alternate which array i'm using; switching between a1[] and b1[].
I'm currently trying to use the cycle() command to accomplish this.
<% @good_bad = [7,6,5,4,3,2,1] %>
<% @bad_good = [1,2,3,4,5,6,7] %>
WITHOUT CYCLE:</br>
<% @super = @bad_good%>
<%= @super%>
<%= @super[0]%>
<%= @super[1]%>
<%= @super[2]%>
WITH CYCLE: </br>
<% @temp_array = cycle(@bad_good , @good_bad , :name => "rating")%>
<%= @temp_array%>
<%= @temp_array[0]%>
<%= @temp_array[1]%>
<%= @temp_array[2]%>
This will display:
ITHOUT CYCLE: 1234567 1 2 3 WITH CYCLE: 1234567 49 50 51
I would expect the print out to be the same since the first cycle it is storing the @temp to @bad_good.
There is probably something basic i'm missing. It's weird how when i try to get the single values of the array it print out 49,50,51, but when i print out the whole array it is accurate?
Any advice appreciated, Thanks, D