gpt4 book ai didi

dictionary - D 中关联数组的常量

转载 作者:行者123 更新时间:2023-12-02 21:37:24 25 4
gpt4 key购买 nike

据我所知,D 中的映射具有值语义。

如果是这样,为什么此示例中的第二行会失败

const(uint[ubyte]) x;
uint[ubyte] y = x;

作为

Error: cannot implicitly convert expression (x) of type const(uint[ubyte]) to uint[ubyte]

什么时候键和值也有值语义?

最佳答案

As far I know maps in D have value semantics.

D 关联数组是引用类型。

在内部,它们表示为指向实现定义的数据结构的指针。 (请注意,如果 AA 为 null,则它的行为不像引用类型,因为添加第一个成员将实例化它。)

关于dictionary - D 中关联数组的常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21079037/

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