Sunday, February 13, 2011

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);
}
}

No comments:

Post a Comment