I create a object myDayForecast with secondary construction, I think the var bb will be empty because the parmater of secondary construction which pass to main construction is HashMap().
I see some document about HashMap(), it will return empty.
But after I run the code, I find the var bb isn't empty (You can see image), why?
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
}
}
Result Image
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…