gpt4 book ai didi

dictionary - 为什么 mutableMapOf 返回可为空的?

转载 作者:行者123 更新时间:2023-12-04 22:18:47 28 4
gpt4 key购买 nike

我写了一个简单的代码块来存储fragmentsidsMap . valuekey的 map 被初始化为不可为空,但是当我想将它们设置为 keyvalue , 它给出 nullable类型数据。所以,我不明白为什么?是否有任何其他类型的 map 返回 non-nullable Kotlin 中的数据?

enter image description here

最佳答案

可能键 [位置] 没有值,这将使其返回 null :

abstract operator fun get(key: K): V?

Returns the value corresponding to the given key, or null if such a key is not present in the map.

关于dictionary - 为什么 mutableMapOf 返回可为空的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45588059/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com