Jakub Gwóźdź
10/12/2018, 2:34 PMdata class Complex(val re: Double, val im: Double)
nice class and a few operators on it and I was so happy that I can do all this z = z * z + c
thingies, wow Kotlin is so great.
Then I was sooooo happy when I figured out I can add val Double.i get() = Complex(0.0, this)
and simply have val z = 3.5.i
And then, just after that, I saw the "Puzzlers" talk. And tried -3.5.i
. Oh boy...elizarov
10/12/2018, 2:35 PMunaryMinus
operator on your complex number and it’ll work just as it is supposed to work.Jakub Gwóźdź
10/12/2018, 2:36 PMelizarov
10/12/2018, 2:38 PM-
and 3.5
(in maths it does not usually matter if you have a space or not)-a.x-b.x-c.x
. Obviously, all .x
shall execute before -
operators (that is how it usually works in math)Jakub Gwóźdź
10/12/2018, 2:42 PM