-2

I am new to scala and don't know what does private[wikipedia]mean,could anyone please tell me?Is it a generic type?

package wikipedia

import scala.io.Source

object WikipediaData {

  private[wikipedia] def lines: List[String] = ???
Dmytro Mitin
  • 48,194
  • 3
  • 28
  • 66
Shengxin Huang
  • 647
  • 1
  • 11
  • 25

2 Answers2

1

It's a way to scope the privacy of a given object. So private[wiki] means only code defined within wiki has access to lines.

See here: https://alvinalexander.com/scala/how-to-control-scala-method-scope-object-private-package/

0x11
  • 173
  • 8
-1

private[packageX] means the following method/class/object/constructor is accessible only from within that package - in this case syntax is the package name, and this constructor is only accessible from other code inside syntax package.

Shengxin Huang
  • 647
  • 1
  • 11
  • 25
  • In `private[X]` `X` can be not only a package. – Dmytro Mitin Dec 02 '20 at 04:00
  • 3
    Currently literal copy of the answer https://stackoverflow.com/a/35929185/5249621 [Is it acceptable to add a duplicate answer to several questions?](https://meta.stackexchange.com/questions/104227/is-it-acceptable-to-add-a-duplicate-answer-to-several-questions) – Dmytro Mitin Dec 02 '20 at 04:01