Scala 中的 _root_ 包是什么? [英] What is the _root_ package in Scala?

查看:21
本文介绍了Scala 中的 _root_ 包是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 IntelliJ IDEA 和 Scala 插件.如果我在代码中引用 HashMap,然后使用 Alt-Enter 添加导入,则包被导入为:

I'm using IntelliJ IDEA with the Scala plugin. If I reference HashMap in code, and then use Alt-Enter to add the import, the package gets imported as:

_root_.scala.collection.immutable.HashMap

root 是什么?无论有没有它,它似乎都可以工作.

What's the root part of this? It seems to work with and without it.

推荐答案

它必须使 Scala 导入是相对的 - _root_ 为您提供了一种指定绝对包名称的方法.请参阅 Scala Wiki

It has to do scala imports being relative - _root_ gives you a way to specify an absolute package name. See the Scala Wiki

这篇关于Scala 中的 _root_ 包是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆