getString(comment) {
const authorName = comment.getAuthor().getName();
if (!comment.getRepliedTo()) return authorName;
return `${comment.getMessage()} by ${authorName} (replied to ${this.getString(comment.getRepliedTo())})`;
}
toString() {
const authorName = this.getAuthor().getName();
if (!this.getRepliedTo()) {
return `${this.message} by ${authorName}`;
}
return this.getString(this);
}
转换为字符串(toString)时,使用以下格式: 没有回复: 邮件+“ by” + author.name 回复: 邮件+“ by” + author.name +“(回复为” + repliedTo.author.name +“)”
但是我仍然通过此消息未能通过测试: toString方法应返回正确的层次结构(无回复)