zoukankan      html  css  js  c++  java
  • Scala中结构类型实战详解之Scala学习笔记-43

    package com.leegh.parameterization

    /**
    * @author Guohui Li
    */

    class Structural { def open() = print("A class instance Opened") }

    object Structural_Type {
    def main(args: Array[String]): Unit = {
    init(new { def open() = println("Opened") })
    //用type关键字创建一个简单的别名
    type X = { def open(): Unit }
    def init(res: X) = res.open()
    init(new { def open() = println("Opened again") })

    object A { def open() { println("A single object Opened") } }
    init(A)

    val structural = new Structural
    init(structural)
    }
    def init(res: { def open(): Unit }) {
    res.open()
    }
    }

    附:

    本博客说明:

    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

  • 相关阅读:
    Solution to LeetCode Problem Set
    《Cracking the Coding Interview》读书笔记
    诗词收集——用于人文素养扫盲
    2015年清华大学计算机系考研总结
    编程知识大杂烩
    hihoCoder 1175:拓扑排序二
    Hackerrank
    Hackerrank
    LeetCode
    LeetCode
  • 原文地址:https://www.cnblogs.com/leegh1992/p/4782723.html
Copyright © 2011-2022 走看看