What is a correct signature of a function with variable length argument list?
Explanation
Get an explanation when it's available:
Theory
  • Scala allows you to indicate that the last parameter to a function may be repeated. This allows clients to pass variable length argument lists to the function. To denote a repeated parameter, place an asterisk after the type of the parameter. For example:
      scala> def echo(args: String*) = 
               for (arg <- args) println(arg)
      echo: (String*)Unit
    
    Defined this way, echo can be called with zero to many String arguments:
      scala> echo()
      
      scala> echo("one")
      one
      
      scala> echo("hello", "world!")
      hello
      world!
    
    Read more: Repeated parameters

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Scala
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты