Scala collection such as List or Sequence or even an Array to variable argument function using the syntax :_ *.

code :

def printReport(names: String*) {
println(s"""Donut Report = ${names.mkString(" - ")}""")
} println("\nStep 3: How to pass a List to a function with variable number of arguments")
val listDonuts: List[String] = List("Glazed Donut", "Strawberry Donut", "Vanilla Donut")
printReport(listDonuts: _*)

result:

Step : How to pass a List to a function with variable number of arguments
Donut Report = Glazed Donut - Strawberry Donut - Vanilla Donut

learning scala How To Create Variable Argument Function - varargs :_ *的更多相关文章

  1. learning scala How To Create Implicit Function

    println("Step 1: How to create a wrapper String class which will extend the String type") ...

  2. learning scala akka actorySystem create and close

    package com.example import akka.actor.ActorSystem import scala.util.{Failure, Success} import scala. ...

  3. c 可变参数(variable argument)的原理及使用

    本文主要介绍可变参数的函数使用,然后分析它的原理,程序员自己如何对它们实现和封装,最后是可能会出现的问题和避免措施. VA函数(variable argument function),参数个数可变函数 ...

  4. How to create DB2 user function easily by DB Query Analyzer 6.03

    How to create DB2user function easily by DB Query Analyzer 6.03 Ma Genfeng (Guangdong Unitoll Servic ...

  5. vs变量监视提示-VAR-CREATE: UNABLE TO CREATE VARIABLE OBJECT解决方法

    昨天有个linux应用在使用vs 远程debug的时候,debug可以正常进行,但是监视变量的时候提示-VAR-CREATE: UNABLE TO CREATE VARIABLE OBJECT,经测试 ...

  6. GreenPlum学习笔记:create or replace function创建函数

    原始表数据如下: 需求:现要求按分号“;”将rate_item列进行分割后插入到新的数据表中. CREATE OR REPLACE FUNCTION fun_gp_test_xxx_20181026( ...

  7. CREATE OR REPLACE FUNCTION

    CREATE OR REPLACE FUNCTION SF_Taishou_Ksai_Date(v_receiptNum IN CHAR,                                ...

  8. CMake语法—普通变量与函数(Normal Variable And Function)

    目录 CMake语法-普通变量与函数(Normal Variable And Function) 1 CMake普通变量与函数示例 1.1 CMakeLists.txt 1.2 执行CMake配置脚本 ...

  9. learning scala Function Recursive Tail Call

    可以使用scala库,可以从字面上看出是在调用 递归函数: code import scala.util.control.TailCalls._ val arrayDonuts: Array[Stri ...

随机推荐

  1. 玫瑰花小制作分享-JavaScript(七夕专属浪漫)

    分享一个玫瑰花的制作小方法,用小小的代码给自己的她送上一个不一样的玫瑰花. 玫瑰花代码由JavaScript实现,JavaScript 作为一种脚本语言, 被发明用于在 HTML 网页上使用,可以给H ...

  2. 【flume】5.采集日志进入hbase

    设置我们的flume配置信息 # Licensed to the Apache Software Foundation (ASF) under one # or more contributor li ...

  3. 设置Echarts图例位置

    只需要修改如下几个示数即可: ①x:可以选择左(left).右(right).居中(center)②y:可以选择左(left).右(right).居中(center)③padding:[0,30,0, ...

  4. CentOS7.9防火墙命令

    CentOS7防火墙命令有变化: CentOS7:   systemctl status firewalld.service     查看防火墙状态 systemctl stop firewalld. ...

  5. VBA嵌套if语句

    一个If或ElseIf语句可以嵌套在另一个If或ElseIf语句中.内部的If语句是根据最外层的If语句执行的.这使得VBScript能够轻松处理复杂的条件. 语法 以下是VBScript中嵌套的If ...

  6. HTML认识一

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  7. Windows下常用DOS命令

    1.添加用户命令: net user 用户名 密码 /add 2.将用户加入组的命令: net localgroup administrators 用户名 /add 3.在dos命令行模式下启用用户: ...

  8. java包装类的自动装箱及缓存

    首先看下面一段代码 public static void main(String[] args) { Integer a=1; Integer b=2; Integer c=3; Integer d= ...

  9. markdown格式字串转html格式字串

    参考:https://www.jianshu.com/p/0eff6cba1b7f 操作: 1.安装python支持包 pip install mkdocs       #  含markdown包 或 ...

  10. c# 接口实现