私は二次構造を持つオブジェクトmyDayForecastを作成しますが、主構造に渡す二次構造のparmaterはHashMap()なのでvar bbは空であると思います。 HashMap()についてのドキュメントを参照してください。空の状態に戻ります。myDayForecast.mapが空でないのはなぜですか?
私はコードを実行した後、var bbが空でないことがわかります(画像が表示されます)。なぜですか?
var myDayForecast= DayForecast(15L,"Desciption",10,5,"http://www.a.com",10L)
var bb=myDayForecast.map
class DayForecast(var map: MutableMap<String, Any?>) {
var _id: Long by map
var date: Long by map
var description: String by map
var high: Int by map
var low: Int by map
var iconUrl: String by map
var cityId: Long by map
constructor(date: Long, description: String, high: Int, low: Int, iconUrl: String, cityId: Long)
: this(HashMap()) {
this.date = date
this.description = description
this.high = high
this.low = low
this.iconUrl = iconUrl
this.cityId = cityId
}
}
あなたはそれでmap to store your property dataを使用している結果画像
なぜこれをJavaとタグ付けしましたか? – Stultuske
あなたが読んでいる本がまだ最後の質問のほとんどに回答していない場合は、Kotlinの紹介としては機能しません。もう1つ読む必要があります。私は前のセクションをもっと慎重に読んだら、それがそれを説明していることがわかります。 –