这不起作用:
let increment(i: int byref) = i <- i + 1
let xxx = ref 0
increment(xxx) // this expression was expected to have type
// byref<int> but here has type int ref
但这有效:
let incrementParam(a: int byref) = a <- a + 1
let mutable b = 30
incrementParam(&b)
还有这个:
type Incrementor =
static member Increment(i : int byref) =
i <- i + 1
let fff = ref 10
Incrementor.Increment(fff)