Skip to content

Commit

Permalink
Return an enumerator if no block is given for walk
Browse files Browse the repository at this point in the history
  • Loading branch information
gjtorikian committed May 18, 2016
1 parent b0b8aca commit 97ee07a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/commonmarker/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Node
#
# blk - A {Proc} representing the action to take for each child
def walk(&block)
return enum_for(:walk) unless block_given?

yield self
each do |child|
child.walk(&block)
Expand All @@ -23,7 +25,7 @@ def to_html(options = :default)
end

# Public: Iterate over the children (if any) of the current pointer.
def each
def each(&block)
return enum_for(:each) unless block_given?

child = first_child
Expand Down

0 comments on commit 97ee07a

Please sign in to comment.