YouTip LogoYouTip

Functions Variable Arguments

Scala Functions – Variable Arguments

-- Learning not just technology, but dreams!

Scala Tutorial Scala TutorialScala IntroductionScala Installation and Environment ConfigurationScala Basic SyntaxScala Data TypesScala Literals Scala Escape Characters Scala VariablesScala Access ModifiersScala OperatorsScala IF...ELSE StatementsScala LoopsScala Methods and FunctionsScala ClosuresScala StringsScala ArraysScala CollectionsScala IteratorsScala Classes and ObjectsScala TraitsScala Pattern MatchingScala Regular ExpressionsScala Exception HandlingScala ExtractorsScala File I/O Scala Loops Scala Closures Deep Dive Scripts Web Design and Development Web Service Development Tools Computer Science Network Services Programming Scripting Languages Programming Languages Software

Scala Functions - Variable Arguments

Image 3: Scala Functions Scala Functions Scala allows you to specify that the last parameter of a function can be repeated, meaning we do not need to specify the number of function parameters, and we can pass a variable-length argument list to the function. Scala sets variable arguments (repeatable parameters) by placing an asterisk after the type of the parameter. For example:
object Test { def main(args: Array) { printStrings("Tutorial", "Scala", "
← Recursion FunctionsFunctions Named Arguments β†’