in Ruby it's easy to tell loop to go to next item
(1..10).each do |a|
  next if a.even?
  puts a
end
result =>
1
3   
5
7
9
but what if I need to call next from outside of the loop (e.g.: method)
def my_complex_method(item)
  next if item.even?  # this will obviously fail 
end
(1..10).each do |a|
  my_complex_method(a)
  puts a
end
only solution I found and works is to use throw & catch like in SO question How to break outer cycle in Ruby?
def my_complex_method(item)
  throw(:skip) if item.even? 
end
(1..10).each do |a|
  catch(:skip) do   
    my_complex_method(a)
    puts a
  end
end
My question is: anyone got any more niftier solution to do this ?? or is throw/catch only way to do this ??
Also what If I want to call my_complex_method not only as a part of that loop (=> don't throw :skip) , can I somehow tell my method it's called from a loop ?
 
     
     
     
    