2020年8月14日

摘要: package chapter04 object test10 { def main(args:Array[String]):Unit={ test[Person10](new Person10) test1[Child10](new Child10) def test[T](t:T):Unit={ 阅读全文
posted @ 2020-08-14 14:19 happygril3 阅读(114) 评论(0) 推荐(0)
摘要: package chapter04 object test09 { def main(args:Array[String]):Unit={ val list = List(1,2,3,4,"abc") val list2: List[AnyVal] = list.map(x => { if (x.i 阅读全文
posted @ 2020-08-14 11:28 happygril3 阅读(114) 评论(0) 推荐(0)
摘要: 如果所有的case都不匹配,那么执行case_分支,类似于Java中的default如果所有的case都不匹配,又没有case_分支,则抛出MatchError每个case都不用break,自动中断casematch中可以使用其他类型,如表达式=>后面的代码块到下一个case,作为一个整体执行,可以 阅读全文
posted @ 2020-08-14 10:05 happygril3 阅读(183) 评论(0) 推荐(0)

导航