This is touching on a pet peeve of mine: Mathematics and programming are similar in many aspects, but this is not one of them. In mathematics = is not a comparison, but a statement.
More generally, mathematics is about tautologies, that is statements that are always true. In programming, a comparison is evaluated to either true or false.
That doesn’t mean that there’s no room for conditionals in mathematics (one example is piecewise function definitions). But it’s not the same. Heck, even the definition of “function” is different between mathematics and programming.
Beware, it’s not always useful to work in complex numbers, you sometimes want to do something different for reals and complex numbers. The prime example here is complex analysis. Defining differentiation is based on limits, on the complex plane there are a lot more directions to approach a limit vs just two on the real line. This has some interesting implications. For example, any function differentiable on the complex plane is infinitely differentiable.