I use a a for loop to populate an array of months each element containing another array of days in that particular month. For examply months[1][0] would be february 1st for whatever year it is. If I populate the array @months using for i in 1...12 it does not include December in the output when I do: <% for month in @months %> <% for day in month %> ...output here... <%end%> <%end%> However, when I populate @months usins for i in 1...13, it includes december? Did somebody add another calendar month that I don''t know about, does for do everything accept the last number in the list, or is something else going on here??? Confused, Sam -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Sam Woodard wrote:> > I use a a for loop to populate an array of months each element > containing another array of days in that particular month. For examply > months[1][0] would be february 1st for whatever year it is. If I > populate the array @months using for i in 1...12 it does not include > December in the output when I do: > > <% for month in @months %> > <% for day in month %> > ...output here... > <%end%> > <%end%> > > However, when I populate @months usins for i in 1...13, it includes > december? Did somebody add another calendar month that I don''t know > about, does for do everything accept the last number in the list, or is > something else going on here??? >LOL (no insults intended)... Actually array indices start at 0. So months[0] will give you Jan. Long www.edgesoft.ca --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Oct 23, 2006, at 12:11 PM, Sam Woodard wrote:> I use a a for loop to populate an array of months each element > containing another array of days in that particular month. For > examply > months[1][0] would be february 1st for whatever year it is. If I > populate the array @months using for i in 1...12 it does not include > December in the output when I do: > > <% for month in @months %> > <% for day in month %> > ...output here... > <%end%> > <%end%> > > However, when I populate @months usins for i in 1...13, it includes > december? Did somebody add another calendar month that I don''t know > about, does for do everything accept the last number in the list, > or is > something else going on here???When creating a range in ruby .. will give you an inclusive range (including your final value) and ... will give you an exclusive range (excluding your final value) So 1..12 -> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] 1...12 -> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] You can find more on ranges at: http://www.ruby-doc.org/core/classes/Range.html James. -- James Stewart : Web Developer Work : http://jystewart.net Play : http://james.anthropiccollective.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---