package scala
import scala.util.control.Breaks
object IfDemo {
def main(args: Array[String]): Unit = {
// val x = -1
// val y=if(x>0) 1 else if (x == -1) 0 else -1
// val str="asdasddsaasdads"
// for(c <- str)println(c)
// val list=Array("hadoop","spark")
// for(a<- list)println(a)
// println(1 to 10)
// var fg=Range(1,100)
// for (dd<- fg if dd%3==0) println(dd)
// for (i <- 'a' to 'f') println(i)
// var a='i' to 'z'
// println(a)
// val i = 1 to 100
// for (a<- i){
// for(a<-i) {
// println(a)
// if (a == 30) {
// return
// }
// }
// }
//def 方法名 参数:参数类型,最多22个 ={方法体}
//指定返回值而没有返回值会八错
// def fun1(x: Int, y: Int): Int = {
// println("")
// }
//
// def fun2(x: Int, y: Int) = x + y
//
// def fun3(x: Int, y: Int) = {
// println("")
// }
//
// def fun4 = {
// println("")
// }
//
// //函数
// val function0 = (x: Int, y: Int) => x * y
// //匿名函数
// (x: Int, y: Int) => x * y
// ()=>x*y
// function0(2,3)
// //完整写法
// val function1:(Int,Int)=>Int=(x,y)=>(x*y)
// for(c<- a if(c%8==0))println(c)
val a=1 to 100
// for(c<-a if(c%2==0)) println(c)
// val function1=(x:Int)=>x%2==0
// val b=a.filter(function1)
// println(b.toBuffer)
// def fun(x:Int)=x%2==0
// val c=a.filter((x:Int)=>x%2==0)
// println(c.toBuffer)
val b=a.filter(_%2==0)
println(b.toBuffer)
}
}