Artificial intelligent assistant

scalaのthis補助コンストラクタに関して scalathis scalathis hoo class hoo(val x: Int, val y: Int){ def this(x: Int){ this(x, x+1) /* */ } } hoobar class bar(val x: Int, val y:Int){ def this(x: Int){ val y = x + 1 /**/ this(x, y) } } valhoobar hoobar Scala =========================================================================== [] this

2(1)

<

> A constructor expression is either a self constructor invocation this(args1args1)……(argsnargsn) or a block which begins with a self constructor invocation. The self constructor invocation must construct a generic instance of the class.




class foo(val x: Int, val y: Int) {
def this(x: Int) = {
this(x, x + 1)
}
}


`this()`Java


class foo {
private final int x;
private final int y;

public foo(int x, int y) {
this.x = x;
this.y = y;
}

public foo(int x) {
final int y = x + 1;
this(x, y); //
}
}


ScalaJava`this()`
()

1

ScalaJava

> thisyhoo classythishoo‌​




`this()``this()`

*
* abstract
* override
*
(…)



etc. ...

`this()`

()
()

IDE

()



`this()`


()






xcX3v84RxoQ-4GxG32940ukFUIEgYdPy e73ee3c29c137d3dc0f9af3af58ad326