首页 > 其他 > 详细

scala学习5--函数二

时间:2016-08-05 17:23:54      阅读:109      评论:0      收藏:0      [点我收藏+]

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
    }
  }

 

scala学习5--函数二

原文:http://www.cnblogs.com/dongdone/p/5742050.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!