swift 中元组

时间:2014-08-27 00:11:16   收藏:0   阅读:194

在swift中元组类似与C语言中的结构体,在一个元组中可以包含多种数据类型,在swift中主要用于函数中做为函数返回值

Example:元组定义

方式一:

let stu: (String,Int,Double,Int) = ("qj",25,175.0,80);

方式二:

let stu1 = (name:"zhsan", age:25);

访问方式:

方式一:stu.0,stu.1....

方式二:let(name,age,height,score) = stu;

name,age...

方式三:stu1.name,sut1.age

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!