scala 继承extends,with浅见_scala with和extends区别-CSDN博客

网站介绍:文章浏览阅读5.7k次,点赞3次,收藏7次。近来学习scala,在继承这一块有一点小小的发现,遂记录下来,以备以后复习之用。1,当with放在子类定义的后面时,输出的结果为:300和150class Animal { val weight = 100 val doubleWeight = 2 * weight}class Tiger extends { override val weight: Int = 150} wit..._scala with和extends区别