Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • submission.getComments().getChildren().get(0).getComment().getAuthor() This is how I get author of first comment of a reddit post, using JRAW(Java reddit API wrapper). How can I avoid chaining in this case. I cannot avoid it. If I write helper function to access it, I will have to do the null check that I mentioned in my question. Commented Jun 12, 2016 at 18:10
  • 1
    @q126y if that's the only option the API gives you, then there's nothing you can do. It's up to the API authors to make another way for you to get a submissions child-comments' authors that doesn't involve chaining like you described. The answers here are written assuming you can change the API. Commented Aug 26, 2017 at 2:09