package scala
import java.io.{FileNotFoundException, IOException}
object Base extends App {
import util.control.Breaks._
breakable{
for (i<-1.to(8)){
break()
}
for (j<- 1 to 8) if (j==2) break()
for (k <- 1 to 8) yield k
}
def sum(x:List[Int])= {
var tmp = 0
for (i <- x) {
tmp += i
}
tmp
}
sum(List(3))
def sumV2(x:Int*)={
x.sum
var res = 0
for (xIter <- x){
res = res+ xIter
}
res
}
sumV2(1 to 8 :_*)
import scala.io.Source
Source.fromFile("path").mkString
Array[Int]().toBuffer
Array.ofDim[Int](3,3)
Array.range(1, 20,2)
""::""::Nil;
(1::0::1::Nil)::(2::(3::(4::Nil)))::(3::(1::(4::Nil)))::Nil
try {
} catch {
case ex: FileNotFoundException =>{
}
case ex: IOException => {
}
}
import scala.collection.immutable
Set(1,2,4,5,3)
}
转载于:https://www.cnblogs.com/mrerror/p/10916309.html