Dream------scala--函数定义、流程控制、异常处理

一、函数的定义

  1、新建工程

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUcAAADpCAIAAAA4SmIWAAAgAElEQVR4nO2df3BTZb7wzwBlHHVwd8eZHWd37s7g+K4yivcdZ98Sr7p3vSsCiiKyKoi6KESsLobS4t0KlNIWaKGxP2gotEBbaEH7uylJm6ZNm/5u01+0JSWF8qMUoWLFzuv7yrzXe94/TnLOc57znJOTX01y+H7mO0xyzvMrIZ88z3mSfEsZZVNXV5ebm9s9NGHtcUD4EiNjNw7lFncPTUBABCIoL6xu7r4A4UsMOybBaojAhTdWN3WNQvgSw47JrKNgdRhHq81hG7ke9GGIhVdWd9ohfImhC9ezjhQF/f8ewutoaOkbGL0R9GGIhcdWd5271th+3m2syTZJh5xGlBrnRq9l5JzsOncNwsfoGLhSeLoqMTklJnZ7TOz2xOSUwtNVHQNXvGhKo9HIL1xT2zQ8dlNmsx617Jfw2OrOwavmtmG3kVHdzURccQvRajmNKDUG7dfSDxd2Dl6F8CUsHSMJe5I1Gk1icgojD3MjYU+ypWPE09Y0Go38wiVl1aPjt8TONrQNp6ZlNnfZW2xjzMBabGPNXfbUtMyGtmEvHqnGhczy3lhd3zokFnECiMXWZJskGpEfptOxi6inN58+55fWZi0Gz19N1xUE3Yqwjvb+ywl7kmNjt5efbWJf952DV8vPNsXGbt+9J6m9b1xmU4dyTrDaHMo5IafKyVPFY1dvi509kJap0Wi+3LEzJnY702xM7PYvd+zUaDSpaZlePFjM6o6By7qj+RLlPba6Y+BKfcs5sRBanXui+JuuqwW9U2zUt5xbk23CKpqsNZufpFgW/aNGohfvguliReqg31v2NAbOX/kqu6Bj4AqE11F4ulKj0ZSfbWLuMi965nb52SaNRlN4ulJmU+394/tStBqNZl+qtr1/XE6V48ePX5q4LXa2qdMe9+UOjYC4L3c2ddq9eLBsCx0DV6w9jv2pWvbBEoNn9Zw5c9jber1+/vz5RKtN1kGxYEzG7sbFxX3TeTW/9xYTJuv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67YROO/D31Zdt1f4YJh0yK3CHVkXUUPhTcPYeuQumIZ9yKQKhTfCt9m82wltlp2+VnR6L3ahtuboutQg9RVrMsotVwu+nXYUQq2UkA5fuBesJSULs9ufaYm8ufHX5pQjqut4cwGoFEypW+5KNMC8vLy4ujvmXnatPD9zccqqOK0SYtwxq/NrSoVULM52wohDP8hHphec3ZrVwFCSksymJzc6CWtx5sFrBhIrVvmQjrK6uzs7OZv5lrRbM1cyE6T7tmGCy5U1/pLPoFOyuF2wFrsbeHcgbXaIXyGw78uZqtChYrWBCwmofsxES52rhCpymaZeVImtQdGeYN6upDaJniYj3wreakrFpJam0YCi87rBR4smbfM3SBIQqSshGKMtqh1aLXByrDTTfF4NW68DzAmNWk8/ycdML6Y1BKi8iKbMhfoygrvMuO2BSMzBXK5iwz0Z4fdiCWi2xW8btWfEuQ9FD3H3kAyPkuppwFofQC7olpyXugTMlBA3yd9koPM8pKXEi4UGB1fccYf/dsuvDFuJ1Nb5bBgD3DOFntRBPrqsBQPkowWoAAFDAagBQGmA1ACgNsBoAlAZYDQBKA6wGAKUBVgOA0gCrAUBpgNUAoDTAagBQGmA1ACgNsBoAlAZYDQBKA6wGAKUBVgOA0gCrAUBpgNUAoDTAagBQGmA1ACgNsBoAlAZYDQBKA6wGAKUBVgOA0gCrAUBpgNUAoDT+P6OSBQ7iZqpkAAAAAElFTkSuQmCC" alt="" />

  2、创建一个object

package com.wls.scala.hello

/**
* Created by wls on 2015年8月11日21:06:332.
*/
object ScalaBasics { def main(args : Array[String]): Unit ={ }
}

  def main(args : Array[String]) : Unit={}

   上面这个就项目于java语言的main方法。(public static void main。。。)------>为什么可以没有static关键字呢

  unit:实际上是这个函数的返回值,unit代表没有,相当于java的void。此处可以去掉,直接写成(def main(args : Array[String]) {})

  3、创建一个函数

 

package com.wls.scala.hello

/**
* Created by wls on 2015年8月11日21:06:332.
*/
object ScalaBasics { //没有参数,没有返回值的普通函数
def dowhile(){
//定义一个变量,(val定义一个产量,注意scala声明参数的时候是没有java中的int、String之类的,他有自动识别类型的功能)
//一般情况使用var、val
var line =""
do{
line =readLine//获取控制台输入写成这样line =readLine()也是可以的
println("Read : "+line)
}while(line !="")
} //main 方法定义的函数
def main(args : Array[String]): Unit ={
//打印一句话,注意scala语法,在这里分号是可以省略的。(scala在设计的时候认为手指多按一个字符都是痛苦的事情)
//println("This is scala")
//调用dowhile函数
dowhile
}
}

  4、一个有参数有返回值得函数

  

  //有参数有返回值的函数
def looper(x : Long, y : Long ) : Long = {
var a = x
var b = y
while(a !=0){
val temp = a
println("temp"+temp)
a = b%a
b = temp
}
b
}
//main 方法定义的函数
def main(args : Array[String]): Unit ={
//打印一句话,注意scala语法,在这里分号是可以省略的。(scala在设计的时候认为手指多按一个字符都是痛苦的事情)
//println("This is scala")
//调用dowhile函数
//dowhile
//调用looper
//这个结果是2,(%,是取余操作),val不是不可变的吗?应该是100啊。注意val产量的生命周期,它声明在了函数体内部
//可以通过debug模式看的一清二楚
println(looper(100,298))
}

二、流程控制

  1、if语句

  def main(args : Array[String]): Unit ={
//如果参数不为空,则把第一个参数赋值给file,否则,把“scala.txt”赋值给file
val file = if(!args.isEmpty) args(0) else "scala.txt"
}

  2、for循环

  

    //打印1--10,,此处实际上1是个对象 ,可以写成1.to(10)
for(i <- 1 to 10){
println("Number is :"+i)
} //增强for循环,获取当前目录下的文件,并循环打印出来
val files = (new File(".")).listFiles()
for(file <- files){
println(file)
}

   3、while do ...while

注意:写在object中的所有内容都是静态的(函数、变量、常量等) ,所以你的代码如果不是在方法区(def定义的函数)而是直接写在了object中,不用调用

    也会执行(类似java的静态代码块)

object ScalaBasics {

  //类似java的静态代码块,无需调用,也会执行,常用于参数初始化
println("Hello wls")
}

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVQAAABECAIAAABRUVrNAAAO5klEQVR4nO2d7VcTVx7H7x+ze1ZZxbp2K9ttPe3Z9ghqWwS6tfXsnnaPiU/Fdm339MFYrAoBHwKamSQIKspTJJAESJCH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0kEpCT+p/ERE61dKwp/opBERpYNSEn648isBAEBpDwaDQTvnM1dMO7cLblmb5BqHiCiuSkn4UQdiV0bgx0AI9+LjpUuucYiI4qSUhB91z0/gJyJanVISftSBsGtvzvJ7XpMFAABZmnluWDT4EVsJ4rM083YlAEp7cF6j4dxE8MaJ7JDYSERECVVKwi+t8s9rshjs7MoIflHhD2/Fbo2eya4EICsri7OpYByyECBKdkXgpyQoSeBHHQgMP2otEB3+6LcP85qsrKwsqKgjRyZ1nyh5FYEf+QVbgi/bShL4JVd+5DP/9VZ+BuoshSKL93xfeBHRhLYmSwCiJFUEfoPBcAUrg8EgF/w0R2uAHz4M9Ku+0N07AFmaH3gLAQCA0ga1iD8p4GtekxW67Q/fViDGYecmbwCJklSJgZ9dZcj1HX5ERESrFW/ZX4mVjMt+7vf2rwH+RCeNiCgdlBj42blI5SciSpQS88Bvncv+RCeNiCgdFIGf/ft5YpLyNdvSv7pb+pgw/KTyExGtX/GDv7e3V6vVarVaiqK439tPURTTvp6/2ENERLRaReBn/pYWRlJey+Erv9PpZL+0m4Wf+QLvqH+rk1R+IiJ5FVf4nzx54nK5dJBcLlfUkUnlJyKSV/GGH+ZfCvlPSOUnIpJb/wc9gZEV0g3kjgAAAABJRU5ErkJggg==" alt="" />

三、异常处理

  

 //异常处理
//和java基本类似,值得注意的是异常的捕获使用的是case,也就是说可以写多个case,(而java是多个catch)匹配第一个,匹配上就抛出
val n = 99
val f = "Spark.txt"
try{
val half = if(n%2==0) n/2 else throw
new RuntimeException("N must be event")
}catch {
//Exception代表异常的类型,=>后面的代表异常怎么处理
case e :FileNotFoundException => {println("The exception is :"+e.getMessage)}
case e :Exception => {println("The exception is :"+e.getMessage)}
}finally {
//释放一些资源啊什么的
}

相关来源:

DT大数据梦工厂,微信公众号是:DT_Spark,每天都会有大数据实战视频发布,请您持续学习。
相关资料:
scala深入浅出实战经典完整视频、PPT、代码下载:
百度云盘:http://pan.baidu.com/s/1c0noOt6
腾讯微云:http://url.cn/TnGbdC
360云盘:http://yunpan.cn/cQ4c2UALDjSKy  访问密码45e2

Dream------scala--函数定义、流程控制、异常处理的更多相关文章

  1. MySQL--视图view、触发器trigger、事务(start transaction)、存储过程(特殊的数据逻辑处理函数)、流程控制(if,case....)

    mysql致力于项目开发及数据库管理之间解耦合(帮忙封装一些数据处理方法,使应用程序的开发者可以专注于应用程序的开发),但受限于不同部门沟通的成本问题,现阶段直接使用的价值不大. 一.视图(只能sel ...

  2. 14 MySQL--事务&函数与流程控制

    一.事务 事务用于将某些操作的多个SQL作为原子性操作,一旦有某一个出现错误,即可回滚到原来的状态,从而保证数据库数据完整性. 一堆sql语句:要么同时执行成功,要么同时失败 # 事务的原子性 场景: ...

  3. [MySQL数据库之Navicat.pymysql模块、视图、触发器、存储过程、函数、流程控制]

    [MySQL数据库之Navicat.pymysql模块.视图.触发器.存储过程.函数.流程控制] Navicat Navicat是一套快速.可靠并价格相当便宜的数据库管理工具,专为简化数据库的管理及降 ...

  4. MySQL知识补充(表字段操作、视图、触发器、事物、存储过程、内置函数、流程控制、索引、慢查询)

    今日内容概要 表字段操作补充(掌握) 视图(了解) 触发器(了解) 事务(掌握) 存储过程(了解) 内置函数(了解) 流程控制(了解) 索引(熟悉) 内容详细 1.表字段操作补充 # 1.添加表字段 ...

  5. mysql:视图、触发器、事务、存储、函数、流程控制

    阅读目录 一 视图 二 触发器 三 事务 四 存储过程 五 函数 六 流程控制 回到顶部 一 视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只 ...

  6. Generator函数在流程控制中的应用

    扯蛋 做了两年的Nodejs全栈开发,不知道为什么跑来做游戏呢(大概是厦门nodejs不好找工作吧).用的是网易的pomelo的游戏框架.现接手了一个棋牌游戏:二十一点,不懂的规则的可以自行百度. 二 ...

  7. Scala(一):函数、流程控制、参数

    Function:函数函数的定义: def 函数名(参数):返回类型=函数实现体 eg:def abs(x:Long) : Long = if(x >= 0) x else -x 你必须给出所有 ...

  8. [原创]Scala学习:流程控制,异常处理

    1.流程控制 1)do..while def doWhile(){ var line="" do{ line = readLine() println("readline ...

  9. Mysql-自带的一些功能,基本用法(视图,触发器,事务,存储过程,函数,流程控制)

    一. 视图 二. 触发器 三. 事务 四. 存储过程 五. 函数 六. 流程控制 一 .视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用 ...

  10. MySQL之视图、触发器、事务、存储、函数、流程控制

    一.视图 视图就是一个虚拟表,我们把复杂的sql语句后看到的虚拟表封装起来,给他取个名字,当我们下次使用的时候,就不用再去写复杂的sql语句,直接调用封装后的视图名字,就可以得到我们想要的表,然后就可 ...

随机推荐

  1. Tomcat 启动流程

  2. ASP.NET MVC中在 @RenderBody() 或者 @Html.Partial()中需要使用引入外部js,css

    今天想在后台封装一下bootstraptree这个插件,引入jquery.js bootstrap.js bootstrap.css bootstrap-tree.js后,我在页面查看脚本错误就连最简 ...

  3. 微信小程序与java后台交互

    java后台使用的ssm框架,小程序连接的本地接口.跟正常的web访问没什么区别,也是后台获取url,返回json数据:只是小程序前台请求的url要带上http://localhost:80801. ...

  4. 查看MySQL最近执行的语句

    首先登入MySQL. Reading table information for completion of table and column names You can turn off this ...

  5. SpringBoot入门系列HelloWorld

    根据咱们程序员学习的惯例,学习一门新技术都是从HelloWorld开始的. 感觉编程是一件非常富有意义的事情,程序员也是一群可爱的人,渴望被关怀和关注,因为我们总在和世界say Hi. 好了进入正题 ...

  6. Spring小节

    Spring的总结 Spring的核心: 1. Spring的两大核心: 1. IOC: 控制反转,将创建(实例化)对象的权利交给Spring容器去进行管理. 2. AOP: 面向切面编程(将切面织入 ...

  7. 解题:CF983B pyramid

    题面 题目都告诉我们是“金字塔”了,不妨分析分析$f$的性质 $f(a_1,a_2)=f(a_1$ $xor$ $a_2)=a1$ $xor$ $a_2$ $f(a_1,a_2,a_3)=f(a_1$ ...

  8. 把矩阵分成n*m个块,从任意一个块出发,问是否可以一笔画遍历矩阵中所有的块

  9. 字符串连接比较(std::unique_ptr实现)

    比较代码之间可能相差大,可是速度相差很大,而且目的在于测试unique_ptr使用...; C/C++: #include <iostream> std::unique_ptr<ch ...

  10. P1099 树网的核 && P2491 [SDOI2011]消防

    给定一棵树, 你可以在树的直径上确定一条长度不超过 \(S\) 的链, 使得树上离此链最长的点距离最小, 输出这个距离 P2491 数据范围为 P1099 的 \(1000\) 倍 Solution ...