From 9c95059018ce022f64034ab5c367c36299a4090f Mon Sep 17 00:00:00 2001 From: Isaiah Zwick-Schachter Date: Wed, 21 Feb 2018 19:59:42 -0500 Subject: [PATCH] Fixed bug on nil comments --- lib/se/api/types/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/se/api/types/post.rb b/lib/se/api/types/post.rb index 303063a..d67de57 100644 --- a/lib/se/api/types/post.rb +++ b/lib/se/api/types/post.rb @@ -14,7 +14,7 @@ def initialize(item_json) @score = @json["score"].to_i @type = @json["post_type"] @last_editor = User.new(@json["last_editor"]) - @comments = @json["comments"].map { |c| Comment.new(c) } + @comments = Array(@json["comments"]&.map { |c| Comment.new(c) }) @id = (@json["post_id"] || @json["answer_id"] || @json["question_id"]).to_i @updated_at = @json["last_activity_date"] @created_at = @json["creation_date"]