<small id='HjUyI'></small><noframes id='HjUyI'>

    1. <legend id='HjUyI'><style id='HjUyI'><dir id='HjUyI'><q id='HjUyI'></q></dir></style></legend>

      <tfoot id='HjUyI'></tfoot>
      • <bdo id='HjUyI'></bdo><ul id='HjUyI'></ul>

        <i id='HjUyI'><tr id='HjUyI'><dt id='HjUyI'><q id='HjUyI'><span id='HjUyI'><b id='HjUyI'><form id='HjUyI'><ins id='HjUyI'></ins><ul id='HjUyI'></ul><sub id='HjUyI'></sub></form><legend id='HjUyI'></legend><bdo id='HjUyI'><pre id='HjUyI'><center id='HjUyI'></center></pre></bdo></b><th id='HjUyI'></th></span></q></dt></tr></i><div id='HjUyI'><tfoot id='HjUyI'></tfoot><dl id='HjUyI'><fieldset id='HjUyI'></fieldset></dl></div>

        减少数组以在 Swift 中设置

        时间:2023-07-08

        1. <small id='4eiPM'></small><noframes id='4eiPM'>

            <tbody id='4eiPM'></tbody>
        2. <legend id='4eiPM'><style id='4eiPM'><dir id='4eiPM'><q id='4eiPM'></q></dir></style></legend>
          • <bdo id='4eiPM'></bdo><ul id='4eiPM'></ul>
                <tfoot id='4eiPM'></tfoot>

                <i id='4eiPM'><tr id='4eiPM'><dt id='4eiPM'><q id='4eiPM'><span id='4eiPM'><b id='4eiPM'><form id='4eiPM'><ins id='4eiPM'></ins><ul id='4eiPM'></ul><sub id='4eiPM'></sub></form><legend id='4eiPM'></legend><bdo id='4eiPM'><pre id='4eiPM'><center id='4eiPM'></center></pre></bdo></b><th id='4eiPM'></th></span></q></dt></tr></i><div id='4eiPM'><tfoot id='4eiPM'></tfoot><dl id='4eiPM'><fieldset id='4eiPM'></fieldset></dl></div>

                  本文介绍了减少数组以在 Swift 中设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图在 Swift 中将对象数组减少为一个集合,这是我的代码:

                  I am trying to reduce an array of objects to a set in Swift and this is my code:

                  objects.reduce(Set<String>()) { $0.insert($1.URL) }
                  

                  但是,我收到一个错误:

                  However, I get an error:

                  Type of expression is ambiguous without more context.
                  

                  我不明白问题出在哪里,因为 URL 的类型肯定是字符串.有什么想法吗?

                  I do not understand what the problem is, since the type of URL is definitely String. Any ideas?

                  推荐答案

                  你不必减少一个数组来把它变成一个集合;只需使用数组创建集合:let objectSet = Set(objects.map { $0.URL }).

                  You don't have to reduce an array to get it into a set; just create the set with an array: let objectSet = Set(objects.map { $0.URL }).

                  这篇关于减少数组以在 Swift 中设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何使用属性观察器观察具有 Swift 集合类型的特定元素? 下一篇:如何在文本转语音中使用印地语(印度母语)语言?

                  相关文章

                  • <bdo id='oB42h'></bdo><ul id='oB42h'></ul>
                  <legend id='oB42h'><style id='oB42h'><dir id='oB42h'><q id='oB42h'></q></dir></style></legend>

                  <small id='oB42h'></small><noframes id='oB42h'>

                    1. <i id='oB42h'><tr id='oB42h'><dt id='oB42h'><q id='oB42h'><span id='oB42h'><b id='oB42h'><form id='oB42h'><ins id='oB42h'></ins><ul id='oB42h'></ul><sub id='oB42h'></sub></form><legend id='oB42h'></legend><bdo id='oB42h'><pre id='oB42h'><center id='oB42h'></center></pre></bdo></b><th id='oB42h'></th></span></q></dt></tr></i><div id='oB42h'><tfoot id='oB42h'></tfoot><dl id='oB42h'><fieldset id='oB42h'></fieldset></dl></div>
                    2. <tfoot id='oB42h'></tfoot>