Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Find#prune
() -> void
Find.prune
lib/find.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/find.rb, line 108
def prune
throw :prune
end
This method is meaningful only within a block given with Find.find.
Inside such a block, “prunes” the traversed file tree by not descending into the current directory:
Example
files = [] Find.find('.') do |path| Find.prune if File.basename(path) == 'test' next unless File.file?(path) && File.extname(path) == '.rb' files << path end files.size # => 6690 files.take(3) # => ["./KNOWNBUGS.rb", "./array.rb", "./ast.rb"]