jweinst1
6/5/2016 - 4:30 PM

using inout parameters on structs

using inout parameters on structs

struct val {
    var f:Int
}

func addto(inout num:val, amount:Int) {
    num.f += amount
}

//inout parameter allows changing value types without reassigning
var test = val(f:8)
addto(&test, amount: 4)
test.f