From: tamouse mailing lists Date: 2013-02-25T00:09:35+09:00 Subject: Re: How should I print only the last combination when using Array#combination(n) ? On Sun, Feb 24, 2013 at 8:55 AM, Love U Ruby wrote: >>> a = [1,2,3] > => [1, 2, 3] > >>> a.combination(2) > => # > >>> a.combination(2).to_a > => [[1, 2], [1, 3], [2, 3]] > >>> a.combination(2){|arr| print arr.length;print "~~>";print arr;print"=>";p arr} > 2~~>[1, 2]=>[1, 2] > 2~~>[1, 3]=>[1, 3] > 2~~>[2, 3]=>[2, 3] > => [1, 2, 3] > > Any chance to get only the last combination,i.e [[2,3]] or 2~~>[2, > 3]=>[2, 3] ? > > -- > Posted via http://www.ruby-forum.com/. > 1.9.3-head :001 > [1,2,3].combination(2).to_a.last => [2, 3]