1.隐式转化的注意事项
image.png2.for的探索
image.pngobject Test6 {
def main(args: Array[String]): Unit = {
var list = List[People](new People("小明",12)
,new People("貂蝉",19),new People("吕布",22)
,new People("刘备",22))
//for循环中的生成器 定义 过滤器
var result = for (index <- list ; n = index.name ; if n.startsWith("刘") ) yield n
println(result)
}
}
class People(val name:String, val age:Int)
3.抽取器和样例类的选择
image.pngimage.png
网友评论