简体   繁体   English

Scala 中的多行包声明

[英]Multi-line package declaration in Scala

I was surprised to learn that there's an alternate syntax for package declaration in Scala:我很惊讶地发现Scala 中有一种用于包声明的替代语法:

package a
package b
package c

(as opposed to package abc ) (相对于package abc

What's the use case for this alternate syntax?这种替代语法的用例是什么? When should I use it instead of the standard one?我什么时候应该使用它而不是标准的?

What's the design rationale behind it?它背后的设计原理是什么?

You get the members of those enclosing packages as it were for free, "visible under their simple names" (9.2 of the spec).您可以免费获得那些封闭包的成员,“以它们的简单名称可见”(规范的 9.2)。

That includes type definitions and functions in the package object.这包括包对象中的类型定义和函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM