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

  • 關於本站
  • 免責聲明