随笔分类 - scala
scala language
摘要:(1)Scala中创建多行字符串使用Scala的Multiline String。 在Scala中,利用三个双引号包围多行字符串就可以实现。 代码实例如: val foo = """a bc d""" 运行结果为: a bc d (2) 上述方法存在一个缺陷问题,输入的内容,带有空格、\t之类,导致
阅读全文
摘要:Option(选项)类型用来表示一个值是可选的(有值或无值)。 Option[T] 是一个类型为 T 的可选值的容器: 如果值存在, Option[T] 就是一个 Some[T] ,如果不存在, Option[T] 就是对象 None
阅读全文
摘要:package com.aura.scala.day01 object sealedClassed { def findPlaceToSit(piece: Furniture) = piece match { case a: Couch => "Lie on the couch" case b: Chair => "Sit on the chair" } } //s...
阅读全文
摘要:code:
阅读全文
摘要:code resule : scala 模式匹配也可以在模式后面加上if <boolean expression> 实现模式守卫。
阅读全文
摘要:code: result:
阅读全文
摘要:数组:可变的,可索引的,元素具有相同类型的数据集合 一维数组 scala> val intValueArr = new Array[Int](3)intValueArr: Array[Int] = Array(0, 0, 0) scala> val myStrArr = Array("BigData
阅读全文
摘要:reference : https://www.jetbrains.com/help/idea/install-and-set-up-product.html env in ubuntu 16.04 install command : lunch command:
阅读全文
摘要:1 .if satement 与其它语言不同的是,scala if statement 返回的是一个值 scala> val a = if ( 6 > 0 ) 1 else -1a: Int = 1 2. while statement 3. do.. while statement 4 for s
阅读全文
摘要:scala读文件: example: scala> import scala.io.Sourceimport scala.io.Source scala> var inputFile = Source.fromFile("text.txt")inputFile: scala.io.BufferedS
阅读全文
摘要:scala 写文件功能: scala> import java.io.PrintWriterimport java.io.PrintWriter scala> val outputFile = new PrintWriter("text.txt")outputFile: java.io.PrintW
阅读全文
摘要:控制台输出语句: print println example: scala> print("i=");print(i)i=345scala> println("hello ");println("world")hello world
阅读全文
摘要:控制台输入语句: readInt, readDouble, readByte, readShort, readLong, readChar, readBoolean, readLine example:scala> import io.StdIn._import io.StdIn._ scala>
阅读全文
摘要:scala 变量: val : 声明时,必须被初始化,不能再重新赋值。 scala> test = "only1"<console>:11: error: not found: value test test = "only1" ^<console>:12: error: not found: va
阅读全文
摘要:scala 操作符: 算术运算符: + - * / % 关系统运算符: > , < ,= ,!= ,>=,<=, 逻辑运算符: && . || , ! 位运算符:&, |, ^,~,<<,>>,>>>(无符号右移) 赋值运算符: = 优先及由上及下
阅读全文
浙公网安备 33010602011771号