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

 

相关文章:

  • 2022-12-23
  • 2021-12-08
  • 2021-12-28
  • 2021-07-31
  • 2021-12-02
  • 2021-11-28
  • 2021-07-18
  • 2021-06-18
猜你喜欢
  • 2021-07-28
  • 2022-12-23
  • 2021-09-25
  • 2021-07-29
  • 2022-12-23
  • 2021-11-27
相关资源
相似解决方案