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( )
原文链接:https://www.f2er.com/swift/327462.html