Constructors in Scala


class R(n: Int, d: Int) {
val (x, y) = {
val g = myfunc
(n/g, d/g)
}
}

class R private (val x: Int, val y: Int);

object R {
def apply(n: Int, d: Int): R = {
val g = myfunc;
new R(n / g, d / g);
}
}

Comments

Popular posts from this blog

NOTES: Web Application Development Sucks (or at least frustrating)

More on getters and setters - Don't do it

JVMNotebook on Google Code