What is the Scala equivalent of the `this` operator in Java? -
In Java, I usually start the field in a constructor like this:
Private Double Actual; Private double fantasy; Public Complexes (double real, double fictional) {this.real = real; This.imaginary = Fictional; } Is there any way to do this in Scala for classes or objects? Something similar:
Like the complex of the class (actual: double, fictional: double) {def re = real def im = / P> < Pre: square compartment (actual: double, fictional: double) {def this =real def = .imaginary = imaginary} Edit: Whoops, I think I find confused methods with fields here.
When you type
in the scales you can automatically To make and start the real and imaginary , the class complex (real: double, imaginary: double) In case you < Code> this . No need to use
Comments
Post a Comment