Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Client.comments() returns array with nil objects? #33

Open
andreimarks opened this issue Oct 25, 2014 · 0 comments
Open

Client.comments() returns array with nil objects? #33

andreimarks opened this issue Oct 25, 2014 · 0 comments

Comments

@andreimarks
Copy link

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?

BukhariH added a commit to BukhariH/RedditKit.rb that referenced this issue Oct 27, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant