Scala中链式调用风格的实现代码实战及其在Spark编程中的广泛运用之Scala学习笔记-41
2015-09-03 13:30
741 查看
package com.leegh.parameterization
/**
* @author Guohui Li
*/
//由于breathe返回的是this,scala将返回类型推断为Animal,而由于Animal没有eat方法
//class Animal { def breathe = this }
//class Cat extends Animal { def eat = this }
class Animal { def breathe: this.type = this }
class Cat extends Animal { def eat: this.type = this }
object Singleton_Types {
def main(args: Array[String]): Unit = {
val cat = new Cat
cat.breathe.eat
}
}
附:
本博客说明:
1.整理思路,提高自己。
2.受教于王家林老师,有所收获,故推荐。
3.博客注重实践,多余的文字就不多说了,都是做技术的。
4.信息来源于 DT大数据梦工厂微信公众账号:DT_Spark。
DT大数据梦工厂的微信公众号是DT_Spark,每天都会有大数据实战视频发布,请您持续学习。
王家林DT大数据梦工厂scala的所有视频、PPT和代码在百度云盘的链接:http://pan.baidu.com/share/home?uk=4013289088#category/type=0&qq-pf-to=pcqq.group
王家林《Scala深入浅出实战初级入门经典视频课程》http://edu.51cto.com/lesson/id-66538.html
王家林《Scala深入浅出实战中级进阶经典视频课程》http://edu.51cto.com/lesson/id-67139.html
/**
* @author Guohui Li
*/
//由于breathe返回的是this,scala将返回类型推断为Animal,而由于Animal没有eat方法
//class Animal { def breathe = this }
//class Cat extends Animal { def eat = this }
class Animal { def breathe: this.type = this }
class Cat extends Animal { def eat: this.type = this }
object Singleton_Types {
def main(args: Array[String]): Unit = {
val cat = new Cat
cat.breathe.eat
}
}
附:
本博客说明:
1.整理思路,提高自己。
2.受教于王家林老师,有所收获,故推荐。
3.博客注重实践,多余的文字就不多说了,都是做技术的。
4.信息来源于 DT大数据梦工厂微信公众账号:DT_Spark。
DT大数据梦工厂的微信公众号是DT_Spark,每天都会有大数据实战视频发布,请您持续学习。
王家林DT大数据梦工厂scala的所有视频、PPT和代码在百度云盘的链接:http://pan.baidu.com/share/home?uk=4013289088#category/type=0&qq-pf-to=pcqq.group
王家林《Scala深入浅出实战初级入门经典视频课程》http://edu.51cto.com/lesson/id-66538.html
王家林《Scala深入浅出实战中级进阶经典视频课程》http://edu.51cto.com/lesson/id-67139.html
相关文章推荐
- ajax传参给php,php连接服务器数据库并返回数据过程详解
- C语言实现冒泡排序-整数排序
- 【软件使用】GitHub使用教程for Eclipse
- 深入Java单例模式
- Java枚举类
- 【C/C++学院】0730-网站以及后门/结构体对齐、结构体面试分析/深拷贝与浅拷贝/队列/字符串封装
- 自学QT之自己写一个窗口
- java中的线程同步问题 模拟出售火车票
- Eclipse Debug的一些用法
- Java并发编程:volatile关键字解析
- C语言链表中数组实现数据选择排序,升序、降序功能主要难点
- C语言链表中数组实现数据选择排序,升序、降序功能主要难点
- java中的线程同步问题解决方案
- 行列式计算(编程实现)
- Python的builtins模块
- 在Ubuntu 14.04 64bit下用Python搭建数据科学研究环境
- C++中构造函数和析构函数的调用顺序
- pycharm templates 设置
- windows核心编程
- 使用Python脚本获取指定格式文件列表的方法