scala学习5--函数二

to 

def  test() : Unit = {
//	  for(i <- 1.to(100)){
//		  println(i)
//	  }
	  for(i <- 1 to 100 ){
		  println(i)
	  }
}

until

def  test2() = {
	for(i <- 1 until 100 ){
		println(i)
	} 
}
def  test3() = {
		for(i <- 0 to 100 if (i % 2) == 1 ; if (i % 5) > 3 ){
		  println("I: "+i)
		}
}

switch

def testmatch(n:Int)={
    n match {
    	case 1 => {println("111") ;n;}
    	case 2 => println("2222") ;n;
    	case _ => println("other"); "test";//default
    }
  }

 

posted @ 2016-08-05 16:58  dongdone  阅读(156)  评论(0编辑  收藏  举报