#Need quick help for the below code snippet

1 messages · Page 1 of 1 (latest)

woeful saddle
#
      try
        {
            
            comments = commentRepository.getAllComments(postId , loggedInUserId);
            replies = replyRepository.getAllReplies(postId , loggedInUserId);
            
        }catch(Exception e) {
            
            comments = List.of();
            replies = List.of();
        }
        
        

        List<CommentReplyDto> commentReplies = comments.stream()
                .map(c -> 
                        new CommentReplyDto
                        (c , replies.stream().
                             filter(r -> r.commentId().equals(c.commentId()))
                             .toList())).toList();

i am getting error local variable replies defined in an enclosing scope must be final or effectively final , why though ?

frail plumeBOT
#

<@&987246883653156906> please have a look, thanks.

woeful saddle
#

have declared them before the try catch block

List<CommentSnippet> comments; 
List<ReplySnippet> replies;
chrome shell
#

please fix your formatting :)