【发布时间】:2014-07-05 16:35:01
【问题描述】:
在objective c中很容易创建一个像这样的异构数组:
NSArray *myArray = @["String1", "String2", 123, 456];
有什么方法可以快速创建这样的数组吗?
如果是,那怎么办?
注意:我在 swift 中尝试过类似的语句 -
var arr = ["string1", "string2", 123, 456]
但它给出了编译错误:
Playground execution failed: error: <REPL>:124:17: error: cannot convert the expression's type 'Array' to type 'IntegerLiteralConvertible'
var arr : Any = ["string1", "string2", 123, 456]
【问题讨论】: