I am encountering this : _* notation in many spark-scala answers, but couldn't find any documentation. What does it mean actually? An example of such usage is in the answer to this question
How to use DataFrame filter with isin in Spark Java?
line:
df.filter(col("something").isin(list: _*)
For a long time, Scala has supported a useful “trick” called infix operator notation. If a method takes a single argument, you can call it without the period after the instance and without parentheses around the argument. This post describes changes in Scala 3.
Regular Expressions explain a common pattern utilized to match a series of input data so, it is helpful in Pattern Matching in numerous programming languages. In Scala Regular Expressions are generally termed as Scala Regex.
Reserved symbols are special character, punctuation that have a special meaning in Scala. They cannot be used as an identifier (variable name or class name). For each reserved symbol there is a list of use cases and for each use case there is a concise explanation.
Scala - Operators - An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Scala is rich in built-in operators and provides the
To understand it, lets take an example
scala> def echo(args: String*) =
for (arg <- args) println(arg)
echo: (args: String*)Unit
scala> val arr = Array("What's", "up", "doc?")
arr: Array[String] = Array(What's, up, doc?)
scala> echo(arr)
<console>:14: error: type mismatch;
found : Array[String]
required: String
echo(arr)
scala> echo(arr: _ *)
What's
up
doc?
This notation,arr:_*
tells the compiler to pass each element of arr as its own argument to echo
, rather than all of it as a single argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With