learning scala pattern matching 03
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的更多相关文章
- learning scala pattern matching 02
code package com.aura.scala.day01 object patternMatching02 { def main(args: Array[String]): Unit = { ...
- learning scala pattern matching
code: package com.aura.scala.day01 import scala.util.Random object patternMatching01 { def main(args ...
- scala pattern matching
scala语言的一大重要特性之一就是模式匹配.在我看来,这个怎么看都很像java语言中的switch语句,但是,这个仅仅只是像(因为有case关键字),他们毕竟是不同的东西,switch在java中, ...
- [Scala] Pattern Matching(模式匹配)
Scala中的match, 比起以往使用的switch-case有著更強大的功能, 1. 傳統方法 def toYesOrNo(choice: Int): String = choice match ...
- Beginning Scala study note(5) Pattern Matching
The basic functional cornerstones of Scala: immutable data types, passing of functions as parameters ...
- Symbols of String Pattern Matching
Symbols of String Pattern Matching in Introduction to Algorithms. As it's important to be clear when ...
- 论文笔记之:MatchNet: Unifying Feature and Metric Learning for Patch-Based Matching
MatchNet: Unifying Feature and Metric Learning for Patch-Based Matching CVPR 2015 本来都写到一半了,突然笔记本死机了 ...
- Zhu-Takaoka Two-dimensional Pattern Matching
Two dimensional pattern matching. Details may be added later.... Corresponding more work can be foun ...
- 配置和运行 MatchNet CVPR 2015 MatchNet: Unifying Feature and Metric Learning for Patch-Based Matching
配置和运行 MatchNet CVPR 2015 GitHub: https://github.com/hanxf/matchnet 最近一个同学在配置,测试这个网络,但是总是遇到各种问题. 我也尝试 ...
随机推荐
- 使用babel es6 转 es5
安装 //Webpack 接入 Babel 必须依赖的模块 npm i -D babel-core babel-loader //preset,告诉babel编译的文件中用到了哪些语法env包含当前所 ...
- 使用 react 的 hooks 进行全局的状态管理
使用 react 的 hooks 进行全局的状态管理 React 最新正式版已经支持了 Hooks API,先快速过一下新的 API 和大概的用法. // useState,简单粗暴,setState ...
- 基于MFC的网页ActiveX控件开发全程实录2(js向ActiveX控件传递参数)
原文转自 https://blog.csdn.net/qianbin3200896/article/details/81452822 1.ActiveX控件部分(JS到ActiveX控件)继续上一篇博 ...
- WebHost.CreateDefaultBuilder
返回WebHostBuilder: 1.用Kestrel做为web服务器,并根据配置提供器内容对其配置. 2.当前目录作为content根目录. 3.从appsettings.json,环境变量,ar ...
- Ubuntu install android studio
Ubuntu install android studio 1. 安装 openjdk8,并在配置文件 /etc/profile 中,追加如下内容: sudo aptitude install ope ...
- jQuery标签操作
样式操作 样式类操作 //添加指定的css类名 $('元素选择器')addClass('类名'); //移除指定的css类名 removeClass(); //判断样式存不存在 hasClass(); ...
- php协议任意文件读取
php://filter/read=convert.base64-encode/resource=index.php
- BLE 广播格式定义
低功耗蓝牙两类报文 : 广播报文 和 数据报文. 本文讨论广播报文数据段,不包括完整报文其他部分,比如前导,接入地址等 蓝牙设备通过广播表明自己的存在,等待被连接, 就好象一个人站在接口大喊“我要脱单 ...
- HBase分布式搭建常见错误
[root@node001 bin]# hbase shell SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found bin ...
- C++——虚函数表解析
转自:https://blog.csdn.net/haoel/article/details/1948051 前言 C++中的虚函数的作用主要是实现了多态的机制.关于多态,简而言之就是用父类型指针指 ...