[String] 和 Array<String> 的区别 [英] Difference between [String] and Array&lt;String&gt;

查看:182
本文介绍了[String] 和 Array<String> 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

声明数组字典哪个更好,我都用过:

Which is better way to declare Array and Dictionary, I have used both:

数组<字符串>

[字符串]

对我来说 [String] 在编码方面非常快,但实际上两者在编译器和性能方面有何不同,我们应该遵循哪一个?

For me [String] is very fast in terms of coding but in reality how both are different in terms of compiler and performance and which one we should follow?

推荐答案

来自 Swift 上的 iOS 开发者库...

From iOS Developer Library on Swift...

Swift 数组的类型全写为 Array<;元素 >,其中元素是数组允许存储的值的类型.你可以还将数组的类型以速记形式写为 [Element].尽管两种形式在功能上是相同的速记形式是首选,并在本指南中提及数组类型.

The type of a Swift array is written in full as Array< Element >, where Element is the type of values the array is allowed to store. You can also write the type of an array in shorthand form as [Element]. Although the two forms are functionally identical, the shorthand form is preferred and is used throughout this guide when referring to the type of an array.

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/CollectionTypes.html

这篇关于[String] 和 Array<String> 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆