Hi I am trying to learn org.apache.spark.ml design. I noticed in that param values are often retrieved by using $ symbol. For example, in NGram.scala
val n: IntParam = new IntParam(this, "n", "number elements per n-gram (>=1)",
ParamValidators.gtEq(1))
/** @group setParam */
def setN(value: Int): this.type = set(n, value)
/** @group getParam */
def getN: Int = $(n)
Is $ a Scala operator with general features?
I can see in eclipse (when I hoverover $(n)
) that it is defined as
final protected def $[T](param: Param[T]): T
but I could not find the class where it was defined the above way.
Can you please tell me where this is defined ?
A dollar sign is a perfectly legal method name in Scala. You can see the definition of this method here.
In this case, it is simply an alias for getOrDefault
.