title: Ruby - unexpected return (LocalJumpError)
body: <p>Ruby 2.0</p>
  
  <p>Why would the code below give unexpected return (LocalJumpError) ?</p>
  
  <pre><code># some code here
  puts "Scanning for xml files .."
  zip_files = Dir.entries(directory).select { |f| File.extname(f) == '.zip' }
  if(zip_files.count == 0)
      puts "No files found, exiting..."
      return
  end
  # more code here ( if files found)
  </code></pre>
  
  <p><code>Error: unexpected return (LocalJumpError)</code></p>
  
  <pre><code>No files found, exiting...
  [Finished in 0.9s with exit code 1]
  </code></pre>