Tag: 哈希

初始化后属性被擦除 – kotlin

我正在使用Kotlin在Android项目中工作。 我有这段代码: val foo = FooClass(this) var colorRunning = FooClass.getProperty(“myproperty”) 和类FooClass是: class FooClass(val context: Context) : SomeHeritance{ private val styles: HashMap = hashMapOf() override fun onCreate(context: Context?) { Log.e(“Hash is empty here”, this.styles.size.toString()) this.styles.put(“a”,”a”) this.styles.put(“b”,”a”) this.styles.put(“c”,”a”) Log.e(“Hash is size is 3”, this.styles.size.toString()) } override fun getProperty(someProp: String) { Log.e(“Hash is size is 0”, this.styles.size.toString()) //I […]