On Tue, Jun 26, 2012 at 5:25 AM, Avdi Grimm <[email protected]> wrote:
> On Mon, Jun 25, 2012 at 9:06 PM, skolo pen <[email protected]> wrote:
>>
>> What method could I use to do the following:
>>
>> people = ["person1","person2","person3"]
>>
>> issue = ["issue1","issue2","issue3","issue4","issue5","issue6"]
>>
>> person1 => issue1
>>
>> person2 => issue2
>>
>> person3 => issue3
>>
>> person1 => issue4
>>
>> person2 => issue5
>>
>> person3 => issue6
>>
>
> people.cycle.take(issue.size).zip(issue)

We can do that shorter

irb(main):004:0> issue.zip(people.cycle)
=> [["issue1", "person1"], ["issue2", "person2"], ["issue3",
"person3"], ["issue4", "person1"], ["issue5", "person2"], ["issue6",
"person3"]]

:-)

Cheers

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to