gpt4 book ai didi

swift - 键 : String value:Array in swift 的扩展字典

转载 作者:行者123 更新时间:2023-11-28 05:49:32 25 4
gpt4 key购买 nike

如何扩展 [String:[Double]] 类型的 Swift 字典?

扩展字典时值要遵循的协议(protocol)/Class_Type 是什么?

[ P.S :在此扩展中,我想返回其值数组包含发送到函数的特定元素 (Double) 的所有键。]

最佳答案

字典有两个通用元素 KeyValue,在您创建扩展时需要对其进行约束。

你可以这样做:

public extension Dictionary where Key == String, Value == [Double] { }

关于swift - 键 : String value:Array in swift 的扩展字典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53391231/

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