F #: How to declare and use ByRef semantics for parameters?

I am distorting some SQL stored procedures with I / O parameters. This, of course, means that I have to do ugly things, such as declaring my parameters as a reference and using mutables.

How do I do this in F #?

+2
source share
1 answer

F # really has a parameter byref. Here is an example MSDN page:

type Incrementor(z) =
    member this.Increment(i : int byref) =
       i <- i + z

( ref mutable, ). MSDN - , /.

:

// Declare a reference.
let refVar = ref 6

// Change the value referred to by the reference.
refVar := 50

:

// Declare a reference.
let mutable refVar = 6

// Change the value referred to by the reference.
refVar <- 50

, ( ) .

+8

All Articles