【Scala】Scala中特殊函数的使用(代码)
这里写的是一些简洁的案例来对这些特殊函数的理解以及解释
object FunDemo2 {//sayHello("老王","你好");/* 调用一个函数的时候,可以指定 参数的名称(必须和函数定义的名称一致)* 不需要安装顺序指定数值* sayHello(msg = "你好",name = "LT")**/def sayHello(name: String,msg:String) = println(s"$name,----$msg")/*** 定义函数的时候,根据给函数的参数赋值,称为参数的默认值* 注意:参数有默认值的话,参数必须放在参数列表最后面* @param name* @param msg*/def sayHello1(name:String,msg:String="Hi..")=println(s"$name,----$msg")def f1():Unit ={println("f1() invoke")//定义内部函数def g():Unit = {println("g1() invoke")}//调用内部函数g()}//参数可变,Java 5 中也提供可变长度参数def printCourses(course:String *):Unit = {course.foreach(item=>println(item))course.foreach(println)}def main(args: Array[String]): Unit = {sayHello("LL","姥姥")printCourses("hadoop","hive")val xx = Array("hadoop","hive","spark")printCourses(xx:_*)//def foreach[U](f:A=>U):Unit ={}xx.foreach((item)=>{})}}
【Scala】Scala中特殊函数的使用(代码)相关推荐
- scala方法中的变量_Scala中的变量
scala方法中的变量 Scala变量 (Scala variables) A variable is named a reference to a memory location. The loca ...
- scala 类中的对象是类_Scala中的类和对象
scala 类中的对象是类 Scala中的课程 (Classes in Scala) A class is a blueprint for objects. It contains the defin ...
- scala中map添加值_如何在Scala Map中反转键和值
scala中map添加值 A Map is a data structure that stores data as key: value pair. 映射是一种将数据存储为键:值对的数据结构. Sy ...
- scala 函数中嵌套函数_Scala中的嵌套函数 用法和示例
scala 函数中嵌套函数 Scala中的嵌套函数 (Nested functions in Scala) A nested function is defined as a function whi ...
- scala 函数中嵌套函数_如何在Scala中将函数转换为部分函数?
scala 函数中嵌套函数 First, let's see what is a function and a partial function, and then we will see their ...
- scala 类中的对象是类_Scala类和对象– Singleton对象,伴侣类
scala 类中的对象是类 Earlier we learned about Scala Programming Language and it's installation on Windows a ...
- scala方法中的变量_Scala变量,变量范围,字段变量,方法参数示例
scala方法中的变量 Variables can be defined as the reserve space in memory to store the assigned values. Ba ...
- scala 函数中嵌套函数_Scala函数–声明,定义,调用和嵌套函数
scala 函数中嵌套函数 A function is a set of statements combined together to perform a specific task. The co ...
- scala 函数中嵌套函数_Scala合成函数
scala 函数中嵌套函数 Scala中的合成功能 (Composition function in Scala) Scala composition function is a way in whi ...
- scala集合中添加元素_如何在Scala中获得列表的第一个元素?
scala集合中添加元素 清单 (List) A list is a linear data structure. It is a collection of elements of the same ...
最新文章
- 澎思科技马原:AI为基,IoT为翼,加速人工智能普惠丨MEET2021
- 技术的不断革新也有负面影响
- chapter 2 自定义数据类型
- 通过excel模板文件根据数据库数据修改其中的单元格数据
- ThinkPHP模型连接数据库 查询 ajax
- OpenJudge NOI 1.9 10:找最大数序列
- JavaScript之常见算法排序
- matlab转python很难吗_MATLAB在逐渐被Python淘汰吗?
- QQ正常网页无法访问故障分析
- Label Matrix v8 怎样做二次开发
- wpf XDG000与XDG0012错误
- thinkpad E430拆装与升级
- 135、137、138、139和445端口
- 计算机c盘能格式化吗,C盘能格式化吗
- Python的文献计量分析流程实现--含代码
- Java实现163网易邮箱消息发送
- partial部分类
- 使用face_recognition:摄像头实时给人脸打马赛克、疲劳检测、活体检测(张嘴检测)、计算两张人脸之间的相似度、人脸校准
- Hadoop 3.0 纠删码技术分析(Erasure Coding)
- 计算机上2个用户,一台电脑上自然人纳税系统可以登录两个账号吗?
热门文章
- git remote(远程仓库操作)
- VMware环境下如何使用iSCSI共享存储(配置实验笔记)
- Spring Cloud与微服务学习总结(13)——云原生趋势下,微服务的拆分粒度如何把握?
- Mysql学习总结(46)——8种常被忽视的SQL错误用法
- Git学习总结(9)——如何构建你自己的 Git 服务器
- Spring MVC学习总结(1)——Spring MVC单元测试
- 2dpsk调制解调实验matlab_ila抓取数据,matlab分析,调试AD9361信号通路
- mysql 语句 not_mysql sql语句 is not 用法是
- 虚拟机续集:自动创建虚拟机virt-install、自动创建快照、kickstart自动安装虚拟机
- linux安装KVM