Scala’s missing splat/underscore operator _* (used as :_*)

The URL I’ve linked to has a discussion on how to use _* as a Scala “splat” operator (also shown as :_*), along with an example of “Scala tuple unpacking.”

The Scala _* syntax is shown in my own example here:

object Test1 extends App {

  def printAll(strings: String*) {
    println("------")
    strings.foreach(println)
  }

  printAll()
  printAll("foo")
  printAll("foo", "bar")
  printAll("foo", "bar", "baz")

  // the special ":_*" syntax
  val fruits = List("apple", "banana", "cherry")
  printAll("numbers", fruits : _*)
  
}
Category