logo
  • 教程列表
  • SO官方文档
  • 范围
    • 公共(默认)范围
    • 私人范围
    • 私有包特定范围
    • 对象私有范围
    • 受保护的范围
    • 包装保护范围
  1. StackOverflow 文档
  2. Scala Language 教程
  3. 范围
  4. 私有包特定范围

私有包特定范围

Created: November-22, 2018

你可以指定可以访问私有值的包。

package com.example {
  class FooClass {
    private val x = "foo"
    private[example] val y = "bar"
  }
  class BarClass {
    val f = new FooClass
    f.x // <- Will not compile
    f.y // <- Will compile
  }
}
  • 对象私有范围
  • 私人范围

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明