Is there an option to call a function by reference?
For example:
if I have a variable x in func1 and I want to send it to func2 so it can change it (without returning its new value etc.)
let func1 =
let mutable x = 1
func2 x
System.Console.WriteLine(x)
let func2 x =
x <- x + 1
So calling func1 will print “2”..
Is it possible? If so, how?
Thanks.
You can use the
&operator andbyrefkeyword.See MSDN: Reference cells (F#) for more information.