/**
* 函数的定义和调用
*/ func showIntegerArray(array:[Int])
{
for a in array
{
println("\(a)")
}
} showIntegerArray([,,]) func maxOfValue(a:Int,b:Int) ->Int
{
return a > b ? a : b
}
println(maxOfValue(,))
func showHelloWord(){
println("Hello World")
}
showHelloWord() let p0:(x:Double,y:Double) = (,)
let p1:(x:Double,y:Double) = (,) func getLengthAndWidth(p0:(x:Double,y:Double),p1:(x:Double,y:Double)) -> (length: Double,width:Double){
return (abs(p0.-p1.),abs((p0.-p1.)))
}
let w = getLengthAndWidth(p0, p1).width
let len = getLengthAndWidth(p0, p1).length
println("\(len):\(w)") /**
* 函数的内部参数和外部参数
*/ //func divisionOpertation(dividend a:Double,divsior b:Double) -> (Double)
//{
// return a / b
//} //加#代表内外参数
func divisionOpertation(#dividend :Double,#divsior :Double) -> (Double)
{
return dividend / divsior
}
let res = divisionOpertation(dividend: 3.5, divsior: 1.2)
println(res) /**
* 函数的默认参数
*/
//func joinString(s1: String,toString s2:String, joiner s3:String = "#")->(String)
//{
// return s1+s3+s2
//
//
//
//} //默认参数可以放到任意位置
func joinString(s1: String,toString s2:String, joiner :String = "?")->(String)
{
return s1+joiner+s2 }
let str = joinString("hello", toString: "world" ,joiner:"#")
println(str) /**
* 常量参数和变量参数
*/
//默认常量不能修改可以起到保护作用
//func swap(var a:Int,var b:Int)
//{
// let t = a
// a = b
// b = t
//}
func swap(inout a:Int,inout b:Int)
{
let t = a
a = b
b = t
} /**
* 输入输出函数(inout)
*/ var x =
var y =
swap(&x, &y) println("\(x),\(y)") /**
* 变参函数
*/

最新文章

  1. Android 学习Activity(1)activity和intent
  2. window对象的属性及事件。
  3. robots.txt文件没错,为何总提示封禁
  4. eclipse上修改js后,浏览器上还是出现原来效果的解决方法
  5. jsp有哪些内置对象?作用分别是什么?分别有什么方法?
  6. Target runtime Apache Tomcat v6.0 is not defined.错误解决方法
  7. Pure-ftpd无法连接到服务器 425错误
  8. struts2+hibernate-jpa+Spring+maven 整合(2)
  9. java数组的拷贝四种方法:for、clone、System.arraycopy、arrays.copyof
  10. CentOS7.2静默安装oracle11g
  11. openstack安装系列问题:window7 64位安装的virtualBox 只能选择32位的系统安装不能选择64位的系统安装
  12. java中判断文件及所在文件夹是否存在
  13. KeyTool 和 OpenSSL 相互转换 [转]
  14. python记录_day17 类与类之间的关系
  15. Spring Boot + Druid 监控数据库(三)
  16. 关于使用MAPVIEWOFFILE大文件的读写(DELPHI版)
  17. arcgis python arcpy add data script添加数据脚本
  18. Atitit opencv3.0  3.1 3.2 新特性attilax总结
  19. 【安装vsftpd】安装vsftpd工具步骤
  20. asp.net core 发布到docker 极简步骤

热门文章

  1. 学习使人快乐9--eclipse常用快捷键总结
  2. java版本的Kafka消息写入与读取
  3. 前端知识体系-NodeJS相关】NodeJS基础知识全面总结
  4. web渗透测试
  5. 配置linux 防火墙,只有固定IP和端口才能能访问完美解决
  6. 利用Flask中的werkzeug.security模块加密
  7. 微信小程序——wx.navigateTo点击后没反应
  8. 007.MongoDB特殊成员
  9. Java实战|Tomcat+Servlet+Sql开发简单网站,从配置环境开始
  10. 攻防世界Web_php_unserialize