Pages

Tuesday, September 27, 2011

Pass in parameter with setter function



Not sure why the pass in parameter's property cannot be invoked. But I found a workaround.

[]
type A =  
    member this.Item
        with get(i:int) : float32 = failwith ".."
        and set (i:int) (v:float32) = failwith ".."

// this version does not work as c is not mutable
// let sample (a:A) (b:A) (c:A) =
//    c.[0] <- a.[0] + b.[0]

you have to use:

let sample (a:A) (b:A) (c:byref)= 
    c.[0] <- a.[0] + b.[0]

No comments: