operator + method

Evaluation operator +(
  1. Evaluation? other
)

Combines two evaluation results.

The reason will be concatenated with a newline, and passed will be combined with an && operator.

Implementation

Evaluation operator +(Evaluation? other) {
  if (other == null) {
    return this;
  }

  final StringBuffer buffer = StringBuffer();
  if (reason != null && reason!.isNotEmpty) {
    buffer.write(reason);
    buffer.writeln();
  }
  if (other.reason != null && other.reason!.isNotEmpty) {
    buffer.write(other.reason);
  }
  return Evaluation._(
    passed && other.passed,
    buffer.isEmpty ? null : buffer.toString(),
  );
}