From: Venkat Surabhi Date: 2011-03-25T16:05:27+09:00 Subject: break from select Hi, I have an array like a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14] I need to select elements which are divisible by 2 and select only 5 elements. col = a.select do |e| e %2 == 0 end I get all the elements into col which are divisible by 2 and working fine. what if I want to select only 5 elements I am trying below code i = 0 col = a.select do |e| i += 1 break if i > 5 e %2 == 0 end Now col returns nil. Also used return but getting error. Any solution for this. Thanks, Venkat -- Posted via http://www.ruby-forum.com/.