- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我们从文档中了解到的:public
属性的 getter 不能是私有(private)的(看起来合乎逻辑),所以:
@Inject
var repository: MyExampleRepository? = null
private get
不会编译。好的,也许我们可以将属性设为 private
并定义 setter public
?
@Inject
private var repository: MyExampleRepository? = null
public set
这将编译并实际注入(inject)值,但我仍然不能在代码中使用它,所以:
service.repository = null
给出编译错误:
Kotlin: Cannot access 'repository': it is 'private' in 'MyService'
我想知道是否有可能拥有公共(public) setter 的私有(private)属性(property)。
最佳答案
这是一个已知问题:KT-10385 :
Kotlin doesn't generate setter method for the following code:
private val someProperty: Integer
public setThe intention is to generate a set only property. Use case including spring dependency injection.
关于kotlin - Kotlin 的属性(property)无障碍,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34569398/
这是我们从文档中了解到的:public 属性的 getter 不能是私有(private)的(看起来合乎逻辑),所以: @Inject var repository: MyExampleReposit
是否可以在没有 block 的情况下使用 GCD?有没有办法像 mikeash 在他的 post 中所说的那样使用 _f 变体来使用 GCD? .我四处寻找,双方都没有证据。是可能还是不可能。 如果可
我一直在努力思考 的用法,以及我应该朝着哪个方向前进最容易接近。 应该总结列:在完美的情况下,每列在 中都有一个相应的摘要单元格. 不幸的是,这种情况几乎从来没有发生过。 通常只有几列包含数字数据
我是一名优秀的程序员,十分优秀!