【问题标题】:What does the ~> operator do? [duplicate]~> 运算符是做什么的? [复制]
【发布时间】:2015-03-21 17:59:19
【问题描述】:

运算符 ~> 在 Swift 中做了什么?

甚至没有关于 swiftdoc.org 或 Xcode 6 的描述。

Xcode 显示有关收集的错误:…does not conform to _CollectionType。如果我使用两个集合,则不会收到非常有用的错误:can not invoke with argument list of (@lvalue [Int], @lvalue [Int])

var coll = [1, 2, 3]
var coll2 = [4, 5, 6]

coll ~> coll2 // error wrong arguments

【问题讨论】:

标签: swift operators


【解决方案1】:

编辑:

查看副本:What is the ~> (tilde greater than) operator used for in Swift?


我只将 ~> 运算符视为特殊的线程运算符。如此处所述:http://ijoshsmith.com/2014/07/05/custom-threading-operator-in-swift/

它需要两个闭包,第一个在后台线程执行,第二个在主线程执行。

请注意,这不是标准的 Swift。

【讨论】:

  • 我认为标准库中定义了一个。我今天试了一下,操场上就知道~> 运算符,而无需导入任何东西。 (首先在 swiftdoc.org 上看到过
  • 我在标准库中没有找到。
  • 这很有趣,它并没有真正记录在案,但它在里面。
猜你喜欢
  • 1970-01-01
  • 2015-10-20
  • 1970-01-01
  • 1970-01-01
  • 2015-03-28
  • 2023-03-05
  • 2013-02-25
  • 2021-02-26
  • 2013-03-29
相关资源
最近更新 更多