When iterating through comments to get all the replies in a tree, I often run into a problem where a nil object is returned as part of the initial comments array, and I'm fairly certain the top level list of comments isn't complete. It happens more frequently on links with > 200 comments.
Example code, in case I'm just missing something basic:
def iterate_through_replies( comment )
replies = comment.replies
if !replies.empty?
replies.each do |r|
iterate_through_replies( r )
end
end
end
link = RedditKit.link( some_full_name )
comments = RedditKit.comments( link.id )
comments.each do |c|
iterate_through_replies( c )
end
At some point this error gets returned:
in 'iterate_through_replies': undefined method 'replies' for nil:NilClass (NoMethodError)
Is a comment getting parsed weirdly? Maybe this is related to this PRAW issue?
When iterating through comments to get all the replies in a tree, I often run into a problem where a nil object is returned as part of the initial comments array, and I'm fairly certain the top level list of comments isn't complete. It happens more frequently on links with > 200 comments.
Example code, in case I'm just missing something basic:
At some point this error gets returned:
in 'iterate_through_replies': undefined method 'replies' for nil:NilClass (NoMethodError)
Is a comment getting parsed weirdly? Maybe this is related to this PRAW issue?