code:

package com.aura.scala.day01

object patternMatching03 {
//当不同类型对象需要调用不同方法时,仅匹配类型的模式非常有用。
def goIDLE(device : Device) = device match {
case p: Phone => p.screenOff
case c:Computer => c.screenSaverOn
}
}
abstract class Device case class Phone(model:String) extends Device{
def screenOff = "Turning screen off"
}

learning scala pattern matching 03的更多相关文章

  1. learning scala pattern matching 02

    code package com.aura.scala.day01 object patternMatching02 { def main(args: Array[String]): Unit = { ...

  2. learning scala pattern matching

    code: package com.aura.scala.day01 import scala.util.Random object patternMatching01 { def main(args ...

  3. scala pattern matching

    scala语言的一大重要特性之一就是模式匹配.在我看来,这个怎么看都很像java语言中的switch语句,但是,这个仅仅只是像(因为有case关键字),他们毕竟是不同的东西,switch在java中, ...

  4. [Scala] Pattern Matching(模式匹配)

    Scala中的match, 比起以往使用的switch-case有著更強大的功能, 1. 傳統方法 def toYesOrNo(choice: Int): String = choice match ...

  5. Beginning Scala study note(5) Pattern Matching

    The basic functional cornerstones of Scala: immutable data types, passing of functions as parameters ...

  6. Symbols of String Pattern Matching

    Symbols of String Pattern Matching in Introduction to Algorithms. As it's important to be clear when ...

  7. 论文笔记之:MatchNet: Unifying Feature and Metric Learning for Patch-Based Matching

    MatchNet: Unifying Feature and Metric Learning for Patch-Based Matching CVPR  2015 本来都写到一半了,突然笔记本死机了 ...

  8. Zhu-Takaoka Two-dimensional Pattern Matching

    Two dimensional pattern matching. Details may be added later.... Corresponding more work can be foun ...

  9. 配置和运行 MatchNet CVPR 2015 MatchNet: Unifying Feature and Metric Learning for Patch-Based Matching

    配置和运行 MatchNet CVPR 2015 GitHub: https://github.com/hanxf/matchnet 最近一个同学在配置,测试这个网络,但是总是遇到各种问题. 我也尝试 ...

随机推荐

  1. Selenium 调用IEDriverServer打开IE浏览器

    Selenium 调用IEDriverServer打开IE浏览器 2016年03月30日 09:49:37 标签: selenium 14836 Selenium 调用IEDriverServer打开 ...

  2. 简单即时通讯、聊天室--java NIO版本

    实现的功能: 运行一个服务端,运行多个客户端.在客户端1,发送消息,其余客户端都能收到客户端1发送的消息. 重点: 1.ByteBuffer在使用时,注意flip()方法的调用,否则读取不到消息. 服 ...

  3. javascript语法糖

    语法糖(Syntactic sugar),也译为糖衣语法 指计算机语言中添加的某种语法,这种语法对语言的功能并没有影响,但是更方便程序员使用. 通常来说使用语法糖能够增加程序的可读性,从而减少程序代码 ...

  4. C# List 转 Tree 公共方法

    # 用C# 写了个List数据结构转树形数据结构的公共扩展方法 /// <summary> /// 将列表转换为树形结构 /// </summary> /// <type ...

  5. element-ui 页面刷新自动弹Message问题

    问题: 通过加载插件的方式引入Message,导致每次页面刷新的时候会自动弹出一个通知消息 该情况只在引入局部插件才会引起 import Vue from 'vue' import 'element- ...

  6. Python实现行列式计算

    数学公式: 代码: # 逆序数 def getInversion(numlist): count = 0 for i in range(1,len(numlist)): subscript = num ...

  7. k8s 开源web操作平台

    https://kuboard.cn/install/install-dashboard.html kuborad

  8. Node.js 实战(一)之—优化汇总

    Express 页面缓存 app.set("cache view",true); --设置页面缓存 开发模式下博主建议不要这么做,因为开发中我们会频繁的对页面的样式.js等进行修改 ...

  9. stm32 SD卡

    容量等级 SD容量有8MB.16MB.32MB.64MB.128MB.256MB.512MB.1GB.2GB SDHC容量有2GB .4GB.8GB.16GB.32GB SDXC容量有32GB.48G ...

  10. 面试常考HTTP协议知识点

    协议简介 1. 应用层协议, 一般以TCP为基础,数据收发通过TCP实现: 2. 一次性连接.服务器与客户端的每次连接只处理一个请求,下次请求重新建立连接: 3. 无状态协议.服务器不保留与客户交易时 ...