Scala 抽象类型Type
来源:互联网 发布:网络伤感情歌大全100首 编辑:程序博客网 时间:2024/05/16 17:30
1、代码
package com.yy.enhance/** * Type:抽象类型 * 抽象类型使用Type关键字定义,在子类中被确定类型 *///抽象类abstract class Animal1{ //使用Type定义抽象类型 type myType //方法的返回值声明为抽象类型 def myfunc():myType}//子类Tigerclass Tiger extends Animal1{ //抽象类型具体化 type myType=String def myfunc()="this is a str"}//子类Catclass Cat extends Animal1{ //抽象类型具体化 type myType=Int def myfunc()=25}//入口object AbstractTypeTest extends App { println(new Tiger().myfunc) println(new Cat().myfunc)}2、结果
this is a str25
0 0
- Scala 抽象类型Type
- scala抽象类型
- scala学习笔记1-泛型、界定、形变、this.type、复合类型、抽象类型
- Scala类型 8:type 关键字
- scala进阶16-抽象类型
- 抽象类型type的使用
- Scala中抽象类型成员 VS 抽象类型参数
- scala 查看对象类型 check type
- Scala入门之高级类型:this.type
- scala进阶14-自身类型self type
- Scala之类型参数化:Type Parameterization
- scala类型系统:8) type关键字
- Scala之类型参数化:Type Parameterization
- Scala 类型: Type vs. Class(类型与类)
- 【Scala类型系统】自身类型(self type)引用
- scala类型系统:3) 单例类型与this.type
- Scala类型 10 :交集类型(intersection type)与联合类型(union type)
- Scala 2.8的新特性:Type Specialization(类型专门化)
- 散列
- 、java能否实现网卡调用
- 写给我的2016
- Spring动态代理机制
- 文档显示部件直接使用javascript脚本介绍
- Scala 抽象类型Type
- 序列化(Serialization)概念
- mysql-MySql优化的一般步骤
- iOS 长按手势
- Django-blog开源
- 点九图
- 减少网卡中断收包产生的CPU消耗
- mysql客户端操作 简数据库建立
- C++小题(六)