我希望为var let map = {
"KeyA" : [123,111,100],
"KeyB" : [147,123,789,111],
"KeyC" : [147,148,789]
};
let checker = (obj, keys, val) => {
return keys.every(k => val.every(v => obj[k].includes(v)));
}
console.log(checker(map, ["KeyA", "KeyB"], [123, 111]));
设置一个值,但是isBackgroundWindow
会导致空错误,为什么?
BTW,代码0 和代码1 错误。
代码0
private var isBackgroundWindow: Boolean by PreferenceTool(this@UIHome, getString(R.string.IsBackgroundName) , false)
代码1
private lateinit var isBackgroundWindow: Boolean
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.layout_home)
isBackgroundWindow= PreferenceTool(this, getString(R.string.IsBackgroundName) , false)
}
代码A
private var isBackgroundWindow: Boolean by lazy {
PreferenceTool<Boolean>(this@UIHome, getString(R.string.IsBackgroundName), false)
}
代码B
class UIHome : AppCompatActivity() {
private var isBackgroundWindow: Boolean by PreferenceTool(this@UIHome, getString(R.string.IsBackgroundName) , false)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.layout_home)
isBackgroundWindow=true
}
}