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. mininet:使用vxlan连接两台虚拟机的网络topo

    需改虚拟机的网络适配器,将其改为host-only 尝试ping宿主机ip地址,此时能够ping同与虚拟机相连的虚拟网卡ip地址,无法ping同其他网卡ip地址 在虚拟机和宿主机中创建网络topo 在 ...

  2. Delphi XE10.1 引用计数(Delphi XE10.1 Berlin终于增加了对接口的Weak, UnSafe的支持)

    以往的Delphi版本,不支持接口的Weak,和UnSafe的引用,支持对象的Weak, UnSafe,而且仅在Android和Ios平台上支持. 现在Delphi XE10.1 Berlin终于增加 ...

  3. THUPC2019/CTS2019/APIO2019/PKUSC2019游记

    THUPC2019/CTS2019/APIO2019/PKUSC2019游记 5.10 中铺,火车好晃啊 5.11 打了THUPC2019的练习赛,华容道好评(四个小兵,杠鸭!) 5.12 打了THU ...

  4. GRIT VIEW删除事件

    1.点选表格后找到事件 RowCommand 2.輸入gvGroupUser_RowCommand后双击                                        ------注分 ...

  5. C# 泛型集合排序

    Student sModel = new Student(); List<Student > list = new List<Student >(); list= list.O ...

  6. Ubuntu下添加定时任务执行php文件

    //添加自动下载定时任务1. vim /etc/crontab2. 添加 #每5分钟执行一次*/5 * * * * root /usr/bin/php /home/wwwroot/123.php3. ...

  7. C# SpinLock用法。

    class Program { static void Main(string[] args) { ; ]; Stopwatch sp = new Stopwatch(); sp.Start(); / ...

  8. java常见排序算法

    今天去面试的时候又考了排序算法,排序这个东西,你以为你懂了,但是真正去写的时候才会发现好多细节自己都模棱两可,我写着写着就全都乱了,回来之后赶紧重新写一遍. (1)冒泡排序 public void b ...

  9. Story of Jerry Wang's Wechat subscription account

    As an SAP Techinical Ambassador,Jerry is always willing to share his SAP expertise to various social ...

  10. django_rest framework 接口开发(一)

    1 restful 规范(建议) 基于FbV def order(request): if request.method=="GET": return HttpResponse(' ...