Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Ruby::Prism::Node#breadth_first_search

breadth_first_search() { |node| ... }

Returns the first node that matches the given block when visited in a breadth-first search. This is useful for finding a node that matches a particular condition.

Example
 node.breadth_first_search { |node| node.node_id == node_id }

: () { (node) -> bool } -> node?