加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala导入中引用的含义是什么

发布时间:2020-12-16 18:13:44 所属栏目:安全 来源:网络整理
导读:我在 scala程序中读了一个import语句: import org.javaswift.joss.command.impl.`object`._ 是什么 “ 意思?谢谢 解决方法 反引号是定义标识符的特殊形式.这在Scala规范 Section § 1.1 (Identifiers)中说明: Finally,an identifier may also be formed b
我在 scala程序中读了一个import语句:

import org.javaswift.joss.command.impl.`object`._

是什么

意思?谢谢

解决方法

反引号是定义标识符的特殊形式.这在Scala规范 Section § 1.1 (Identifiers)中说明:

Finally,an identifier may also be formed by an arbitrary string
between back-quotes (host systems may impose some restrictions on
which strings are legal for identifiers). The identifier then is
composed of all characters excluding the backquotes themselves.

当您需要使用保留关键字作为标识符时使用.在这种情况下,object是一个保留关键字,用于在Scala中创建单例类型:

The following names are reserved words instead of being members of the
syntactic class id of lexical identifiers:

abstract    case        catch       class       def
do          else        extends     false       final
finally     for         forSome     if          implicit
import      lazy        macro       match       new
null        object      override    package     private
protected   return      sealed      super       this
throw       trait       try         true        type
val         var         while       with        yield
_    :    =    =>    <-    <:    <%     >:    #    @

因为对象是在保留关键字中指定的,所以我们使用反引号来解决这个问题,并允许编译器为导入赋予正确的含义.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读