One is able to define methods without paranthesis if they have no arguments. A special use-case is to use this to get values. Should I do this, or rather directly get the value?
So
class Complex(real: Double, imaginary: Double) {
def re = real
def im = imaginary
override def toString() =
"" + re + (if (im < 0) "" else "+") + im + "i"
}
or
class Complex(real: Double, imaginary: Double) {
val re = real
val im = imaginary
override def toString() =
"" + re + (if (im < 0) "" else "+") + im + "i"
}