What is the limit (if any) to the tuple cardinality in Swift?(Swift 中元组基数的限制(如果有的话)是什么?)
问题描述
每个元组基数都由它自己的 swift 类型表示(就像我知道的任何其他强类型编程语言一样),所以我们有
Each tuple cardinality is represented by its own type in swift (as in any other strongly-typed programming language I'm aware of), so we have
($T1, $T2)
($T1, $T2, $T3)
...
由于我们有几种不同的类型,每种基数一种,它们必须是有限的.
Since we have several different types, one per cardinality, they need to be finite.
在 Scala 中,我们最多有 Tuple22,在 Haskell 中,当前限制应该是 64.
In Scala we have up to Tuple22, in Haskell the current limit should be 64.
swift 有什么限制(如果有的话)?另外,是编译器生成的类型实现还是我找不到的显式实现?
What's the limit (if any) in swift? Also, are the types implementations generated by the compiler or is there an explicit implementation I couldn't find?
推荐答案
在当前版本的 Xcode 6 Beta 中,编译失败,元组的元组大于 1948(swift 可执行文件以代码 254 退出; 没有具体的警告或错误).
In the current version of Xcode 6 Beta, compilation fails with tuples of arity larger than 1948 (the swift executable exits with code 254; there isn't a specific warning or error).
这篇关于Swift 中元组基数的限制(如果有的话)是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Swift 中元组基数的限制(如果有的话)是什么?
				
        
 
            
        基础教程推荐
- Android Volley - 如何动画图像加载? 2022-01-01
 - UIImage 在开始时不适合 UIScrollView 2022-01-01
 - Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
 - SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
 - 如何比较两个 NSDate:哪个是最近的? 2022-01-01
 - 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
 - 如何将图像从一项活动发送到另一项活动? 2022-01-01
 - Play 商店的设备兼容性问题 2022-01-01
 - navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
 - iOS - UINavigationController 添加多个正确的项目? 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
				
				
				
				