As others have mentioned, it's an import rename. There is however one further feature that proves astoundingly-useful on occasion that I would like to highlight: If you "rename" to _, the symbol is no longer imported.

This is useful in a few cases. The simplest is that you'd like to do a wildcard import from two packages, but there's a name that's defined in both and you're only interested in one of them:

import java.io.{ File=>_, _ }
import somelibrary._

Now when you reference File, it will unambiguously use the somelibrary.File without having to fully-qualify it.

In that case, you could have also renamed java.io.File to another name to get it out of the way, but sometimes you really do not want a name visible at all. This is the case for packages that contain implicits. If you do not want a particular implicit conversion (e.g. if you'd rather have a compile error) then you have to delete its name completely:

import somelibrary.{RichFile => _, _}
// Files now won't become surprise RichFiles

参考链接:

https://stackoverflow.com/questions/31652959/what-does-mean-in-import-in-scala

What does “=>” mean in import in scala?(转自StackOverflow问答)的更多相关文章

  1. Scala 面向对象(四):import

    1 Scala引入包基本介绍 Scala引入包也是使用import, 基本的原理和机制和Java一样,但是Scala中的import功能更加强大,也更灵活. 因为Scala语言源自于Java,所以ja ...

  2. Beginning Scala study note(9) Scala and Java Interoperability

    1. Translating Java Classes to Scala Classes Example 1: # a class declaration in Java public class B ...

  3. Scala _ [underscore] magic

    I started learning Scala a few days before. Initially i was annoyed by the use of too many symbols i ...

  4. Scala 编程(一)Scala 编程总览

    Scala 简介 Scala 属于“可伸展语言”,源于它可以随使用者的需求而改变和成长.Scala 可以应用在很大范围的编程任务上,小到脚本大到建立系统均可以. Scala 跑在标准 Java 平台上 ...

  5. scala的多种集合的使用(1)之集合层级结构与分类

    一.在使用scala集合时有几个概念必须知道: 1.谓词是什么? 谓词就是一个方法,一个函数或者一个匿名函数,接受一个或多个函数,返回一个Boolean值. 例如:下面方法返回true或者false, ...

  6. Scala - 快速学习01 - Scala简介

    Scala简介 Scala(Scalable Language)是一门多范式(multi-paradigm)编程语言,Scala的设计吸收借鉴了许多种编程语言的思想,具备面向对象编程.函数式编程等特性 ...

  7. scala程序开发入门

    scala程序开发入门,快速步入scala的门槛: 1.Scala的特性: A.纯粹面向对象(没有基本类型,只有对象类型).Scala的安装与JDK相同,只需要解压之后配置环境变量即可:B.Scala ...

  8. mac平台scala开发环境搭建

    到scala官网,下载scala的sdk,地址:http://www.scala-lang.org/download/ adeMacBook-Pro:scala- apple$ wget http:/ ...

  9. Scala学习笔记--xml

    http://blog.csdn.net/beautygao/article/details/38497065 https://github.com/scala/scala-xml http://st ...

随机推荐

  1. 电子商务(电销)平台中财务模块(Finance)数据库设计明细

    以下是自己在电子商务系统设计中的数据库设计经验总结,而今发表出来一起分享,如有不当,欢迎跟帖讨论~ 资金账户表 (finance_account)|-- 自动编号|-- 用户编号|-- 预付款 (ad ...

  2. BZOJ #3746: [POI2015]Czarnoksiężnicy okrągłego stołu 动态规划

    转载请注明出处:http://www.cnblogs.com/TSHugh/p/8823423.html 读完题就会发现p=0.1的情况以及n=1.2的情况都可以直接判掉,而p=2的时候也可以直接构造 ...

  3. python创建多维列表

    By francis_hao    Mar 24,2018   "*"操作符可以用于列表,表示将列表内容重复n次.如下,   但是当列表内容是列表的时候就出问题了,如果我只是修改多 ...

  4. 把一个文件中所有文件名或者文件路径读取到一个txt文件,然后在matlab中读取

    链接: http://blog.csdn.net/dreamgchuan/article/details/51113295 dir /on/b/s  这个读取的是这样的格式:

  5. 4.UiCollection API 详细介绍

    一.UiCollection类介绍 UiCollection类两大功能:从集合中查找对象:获取某种搜索条件组件的数量 1.UiCollection类说明 1)UiCollection是UiObject ...

  6. linux python3获取ip地址

    一.不带参数 #!/usr/bin/python # -*- coding: UTF-8 -*- import os def get_ip(): #注意外围使用双引号而非单引号,并且假设默认是第一个网 ...

  7. Nginx修改access.log日志时间格式

    一.修改原因 因为要获取nginx访问信息,作为开发的数据使用,但是nginx的access.log文件中的默认的时间格式是这样的: [02/Nov/2017:20:48:25 +0800] 而要求的 ...

  8. P3620 [APIO/CTSC 2007]数据备份

    P3620 [APIO/CTSC 2007]数据备份 题目描述 你在一家 IT 公司为大型写字楼或办公楼(offices)的计算机数据做备份.然而数据备份的工作是枯燥乏味的,因此你想设计一个系统让不同 ...

  9. [DeeplearningAI笔记]序列模型2.9情感分类

    5.2自然语言处理 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2.9 Sentiment classification 情感分类 情感分类任务简单来说是看一段文本,然后分辨这个人是否喜欢 ...

  10. 51nod 1171 大灾变

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1757 二分答案mid 避难所拆为mid个点 每个避难所的第一个点向第二个 ...