diff --git a/src/complex.cr b/src/complex.cr index 4b6482e9efad..e58fe02ac4ae 100644 --- a/src/complex.cr +++ b/src/complex.cr @@ -251,6 +251,16 @@ struct Complex new 0, 0 end + # Returns `true` if the complex number is zero. + # This means the real and imaginary are both zero. + # + # ``` + # require "complex" + # + # Complex.new(0, 0).zero? # => true + # Complex.new(1, 0).zero? # => false + # Complex.new(0, 1).zero? # => false + # ```` def zero? : Bool @real == 0 && @imag == 0 end