swift 函数返回值
2015-11-10 11:01
381 查看
函数的定义及调用
func开头作为前缀,->返回的类型
add输出结果是11
函数参数也可以有多个参数,写在括号里用逗号隔开。
无参函数
多重返回值函数
func开头作为前缀,->返回的类型
add输出结果是11
函数参数也可以有多个参数,写在括号里用逗号隔开。
func introduce(name: String,age: Int) -> String { return "\(name),I'm \(age) year old now." } introduce("Zing",18)
无参函数
func helloWorld() { return "hello world" } print(helloWorld())
多重返回值函数
func operation(pending: Int...) ->(add: Int,ride: Int) { var ad = 0,ri = 1 for a in add { ad+=a } for r in ride { ri*=r } return (ad,ri) } let result = operation(5,10,10) print("加\(result.add),乘\(result.ride)")
相关文章推荐
- swift 快速奔跑的兔几 本节的内容是:SpriteKit第5讲 形状节点 图像特效节点
- swift 快速奔跑的兔几 本节的内容是:SpriteKit第4讲 字体和动画
- Swift中获取系统语言
- swift 遍历
- Swift基本语法以及与OC的比较
- swift中的类和结构
- 如何在swift中实现oc中的分类
- Swift里类的初始化相关内容(重要)
- pod 遇到无法 pod install 或者 pod update Pods written in Swift can only be integrated as frameworks; this
- IOS_Swift_?和!区别
- swift 快速奔跑的兔几 本节的内容是:SpriteKit第三讲 纹理和纹理贴图集
- swift 彻底解决_OBJC_CLASS_$_某文件名", referenced from:问题
- swift 彻底解决_OBJC_CLASS_$_某文件名", referenced from:问题
- 理解 OpenStack Swift (1):OpenStack + 三节点Swift 集群+ HAProxy + UCARP 安装和配置
- swift 快速奔跑的兔几 本节的内容是:SpriteKit第二讲
- swift 与 指针初级使用
- swift 手势识别
- swift 手势识别
- Swift的一些基础内容
- iOS9+Swift开发经验不定期汇总(2): 企业账号应用不受信任,自定义Navigation Controller左上角返回按钮,CLLocationManager停止获取GPS等