operator + method

  1. @override
Expression operator +(
  1. EquationMember m
)
override

Creates a Expression by adding this member with the argument. Both members may need to be hoisted to expressions themselves before this can occur.

For example: (left + right) / cm(2.0) can be used as an Expression equivalent of the midPointX property.

Implementation

@override
Expression operator +(EquationMember m) {
  if (m is ConstantMember) {
    return Expression(List<Term>.from(terms), constant + m.value);
  }

  if (m is Param) {
    return Expression(
      List<Term>.from(terms)..add(Term(m.variable, 1)),
      constant,
    );
  }

  if (m is Term) {
    return Expression(List<Term>.from(terms)..add(m), constant);
  }

  if (m is Expression) {
    return Expression(
      List<Term>.from(terms)..addAll(m.terms),
      constant + m.constant,
    );
  }
  throw Exception();
}