import UIKit
func trytochangeValue( var x:Int ){x++}
var a:Int = 2
tyrChangeValue(a)
a
var b:Int = a
b
b++
b
a
Value Type and Reference Type
Int,float,Double,Bool
Tuple
-> Value Type
String,Array,Dictionary
Function,Closure -> Reference Type
import UIKit
func calcTotalMiles( todayMiles:Int ) -> ( ) -> Int{
var totalMiles = 0
return {totalMiles += todayMiles; return totalMiles;}
}
var dailyTwoMiles = calcTotalMiles(2)
dailyTwoMiles()
dailyTwoMiles()
dailyTwoMiles()
var dailyThreeMiles = calcTotalMiles(3)
dailyThreeMiles( )
dailyThreeMiles( )
dailyThreeMiles( )
var myPlan = dailyTwoMiles
maPlan()
dailyTwoMiles( )
总结
以上是内存溢出为你收集整理的值类型和引用类型全部内容,希望文章能够帮你解决值类型和引用类型所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)