Question on Spark code

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question on Spark code

tao zhan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question on Spark code

rxin
It means the same object ("this") is returned.

On Sun, Jul 23, 2017 at 8:16 PM, tao zhan <[hidden email]> wrote:

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question on Spark code

M. Muvaffak ONUŞ
Doesn't it mean the return type will be type of "this" class. So, it doesn't have to be this instance of the class but it has to be type of this instance of the class. When you have a stack of inheritance and call that function, it will return the same type with the level that you called it.

On Sun, Jul 23, 2017 at 8:20 PM Reynold Xin <[hidden email]> wrote:
It means the same object ("this") is returned.

On Sun, Jul 23, 2017 at 8:16 PM, tao zhan <[hidden email]> wrote:

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question on Spark code

tao zhan
Thank you for replying.
But I do not get it completely, why does the "this.type“” necessary? 
why could not it be like:

def setStepSize(step: Double): Unit = {
    require(step > 0,
      s"Initial step size must be positive but got ${step}")
    this.stepSize = step
}

On Mon, Jul 24, 2017 at 11:29 AM, M. Muvaffak ONUŞ <[hidden email]> wrote:
Doesn't it mean the return type will be type of "this" class. So, it doesn't have to be this instance of the class but it has to be type of this instance of the class. When you have a stack of inheritance and call that function, it will return the same type with the level that you called it.

On Sun, Jul 23, 2017 at 8:20 PM Reynold Xin <[hidden email]> wrote:
It means the same object ("this") is returned.

On Sun, Jul 23, 2017 at 8:16 PM, tao zhan <[hidden email]> wrote:


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question on Spark code

rxin
This is a standard practice used for chaining, to support

a.setStepSize(..)
  .set setRegParam(...)


On Sun, Jul 23, 2017 at 8:47 PM, tao zhan <[hidden email]> wrote:
Thank you for replying.
But I do not get it completely, why does the "this.type“” necessary? 
why could not it be like:

def setStepSize(step: Double): Unit = {
    require(step > 0,
      s"Initial step size must be positive but got ${step}")
    this.stepSize = step
}

On Mon, Jul 24, 2017 at 11:29 AM, M. Muvaffak ONUŞ <[hidden email]> wrote:
Doesn't it mean the return type will be type of "this" class. So, it doesn't have to be this instance of the class but it has to be type of this instance of the class. When you have a stack of inheritance and call that function, it will return the same type with the level that you called it.

On Sun, Jul 23, 2017 at 8:20 PM Reynold Xin <[hidden email]> wrote:
It means the same object ("this") is returned.

On Sun, Jul 23, 2017 at 8:16 PM, tao zhan <[hidden email]> wrote:



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question on Spark code

tao zhan
Get it, thank you!

On Mon, Jul 24, 2017 at 11:50 AM, Reynold Xin <[hidden email]> wrote:
This is a standard practice used for chaining, to support

a.setStepSize(..)
  .set setRegParam(...)


On Sun, Jul 23, 2017 at 8:47 PM, tao zhan <[hidden email]> wrote:
Thank you for replying.
But I do not get it completely, why does the "this.type“” necessary? 
why could not it be like:

def setStepSize(step: Double): Unit = {
    require(step > 0,
      s"Initial step size must be positive but got ${step}")
    this.stepSize = step
}

On Mon, Jul 24, 2017 at 11:29 AM, M. Muvaffak ONUŞ <[hidden email]> wrote:
Doesn't it mean the return type will be type of "this" class. So, it doesn't have to be this instance of the class but it has to be type of this instance of the class. When you have a stack of inheritance and call that function, it will return the same type with the level that you called it.

On Sun, Jul 23, 2017 at 8:20 PM Reynold Xin <[hidden email]> wrote:
It means the same object ("this") is returned.

On Sun, Jul 23, 2017 at 8:16 PM, tao zhan <[hidden email]> wrote:




Loading...