I have a sorting and collecting question say i have a array with 18 elements and each element is storing 5 numbers i want to collect each of the 5 numbers out of the that index of the array and store there values into different arrays what would be the easiest and dryest way of complete this task example array[0..18] array[0] => [ 1 2 3 4 5 ] thanks for any help Gabriel G --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
GabrielG1976 wrote:> I have a sorting and collecting question say i have a array with 18 > elements and each element is storing 5 numbers > i want to collect each of the 5 numbers out of the that index of the > array and store there values into different arrays what would be the > easiest and dryest way of complete this task > > example array[0..18] > array[0] => [ 1 2 3 4 5 ] > > thanks for any help > > Gabriel G"store their values into different arrays" - can you supply more details about what you want to do with the numbers? -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
What it is a Golf score keeper each of the game[0..17] array elements is a round or 1 hole in golf the first number is what par is and each of the 4 golfers strokes taken at that hole game[0] => [ 1 2 3 4 5 ]> thanks for any help > > > Gabriel G > > "store their values into different arrays" - can you supply more details > about what you want to do with the numbers? > -- > Posted viahttp://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?hl=en -~----------~----~----~----~------~----~------~--~---
GabrielG1976 wrote:> What it is a Golf score keeper each of the game[0..17] array elements > is a round or 1 hole in golf > the first number is what par is and each of the 4 golfers strokes > taken at that hole game[0] => [ 1 2 3 4 5 ]what about something like (I assume you want five arrays out of this) If round is your starting array like [[4, 4, 3, 4, 5],[4, 4, 4, 4, 5],[3, 2, 3, 3, 4],...] (yeah, that last golfer must be me) par = [] golfer1 = [] golfer2 = [] golfer3 = [] golfer4 = [] round.each do |scores| par << scores[0] golfer1 << scores[1] etc end I''m sure there''s a more cryptographic way to do it that takes less keystrokes, but I value clarity. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for everyones help Gabriel On Jun 13, 1:24 pm, Ar Chron <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> GabrielG1976 wrote: > > What it is a Golf score keeper each of the game[0..17] array elements > > is a round or 1 hole in golf > > the first number is what par is and each of the 4 golfers strokes > > taken at that hole game[0] => [ 1 2 3 4 5 ] > > what about something like (I assume you want five arrays out of this) > If round is your starting array like [[4, 4, 3, 4, 5],[4, 4, 4, 4, > 5],[3, 2, 3, 3, 4],...] (yeah, that last golfer must be me) > > par = [] > golfer1 = [] > golfer2 = [] > golfer3 = [] > golfer4 = [] > round.each do |scores| > par << scores[0] > golfer1 << scores[1] > etc > end > > I''m sure there''s a more cryptographic way to do it that takes less > keystrokes, but I value clarity. > -- > Posted viahttp://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?hl=en -~----------~----~----~----~------~----~------~--~---