operator == method

  1. @override
bool operator ==(
  1. Object b
)
override

Compare two complex number

Examples

var c1 = Complex(real: 1, imaginary: -3);
var c2 = Complex(real: 1, imaginary: 2);

print(c1 == c2);

/* output:
false
*/

Implementation

@override
bool operator ==(b) {
  if (b is Complex) {
    return b.real == real && b.imaginary == imaginary;
  } else {
    throw ('the right object has to be a Complex type');
  }
}