From: Robert Klemme Date: 2012-02-06T17:13:38+09:00 Subject: Re: how to exit from outerblock On Mon, Feb 6, 2012 at 8:43 AM, Lucky Nl wrote: > I have 2 blocks .i want exit innerblock and outer block if condition > failed > > gnerally break will exit from innerblock > > > a=[1,2,3,4,5,6] > b=[5,2,3] > a.each do |e| > puts e > b.each do |q| > break if q==e > end > end > > here if q==e.it should exit from b and a blocks "e.it" is a Groovyism. We're in the realms of Ruby here. :-) Question is, what do you want to achieve? Chances are that you want #find for this use case: irb(main):001:0> a=[1,2,3,4,5,6] => [1, 2, 3, 4, 5, 6] irb(main):002:0> b=[5,2,3] => [5, 2, 3] irb(main):003:0> a.find do |e| irb(main):004:1* puts e irb(main):005:1> b.include? e irb(main):006:1> end 1 2 => 2 But what problem are you trying to solve? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/