From: sto.mar@... Date: 2013-02-25T03:19:52+09:00 Subject: Re: How should I print only the last combination when using Array#combination(n) ? Am 24.02.2013 17:11, schrieb Love U Ruby: > see the below code : > >>> a = [1,2,3,4,5] > => [1, 2, 3, 4, 5] >>> a.combination(3){|arr| p arr} > [1, 2, 3] > [1, 2, 4] > [1, 2, 5] > [1, 3, 4] > [1, 3, 5] > [1, 4, 5] > [2, 3, 4] > [2, 3, 5] > [2, 4, 5] > [3, 4, 5] > => [1, 2, 3, 4, 5] > > Here,say I want to see the output only(without any fancy I write it > here,just to get to see the trick): > > [1, 3, 5] #~~ means 5th combination > [2, 3, 5] #~~ means 8th combination > > But yes only with block. Why??? What are you trying to do? Why do you insist on using a block? What is your use case? We can give better advice when you tell us what you are trying to accomplish. Using a block might not be the most effective solution. --