如何界定斯威夫特倒闭的阵列? [英] How to define array of closures in Swift?
本文介绍了如何界定斯威夫特倒闭的阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要定义是这样的:
public var reloadFRCsNeedToPerformWhenFail = [()->()]()
但我得到一个错误
but I get an error
推荐答案
这样的:
public var reloadFRCsNeedToPerformWhenFail : [()->()] = []
如果你使用一个类型别名,使() - GT;()
A型,你可以做你的方式:
If you use a type alias to make ()->()
a type, you can do it your way:
public typealias VoidVoid = ()->()
public var reloadFRCsNeedToPerformWhenFail = [VoidVoid]()
或者,放弃了 []
快捷方式符号和使用完整的通用的:
Or, forego the []
shortcut notation and use the full generic:
public var reloadFRCsNeedToPerformWhenFail = Array<()->()>()
这篇关于如何界定斯威夫特倒闭的阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文