How to set argument [<Out>]?

I use the argument: [<Out>] message : string

But when I try to set it: message <- "there is no digit in the starting position"

I get an error because the message does not change. How to specify an argument?

+4
source share
2 answers

Enter a method method with type byref<string> and attribute [<Out>] and use a mutable value with the operator address & as an argument:

 open System.Runtime.InteropServices let mutable msg = "abc" let outmsg ([<Out>]message : byref<string>) = message <- "xyz" msg <- "test" outmsg(&msg) msg;; val mutable msg : string = "xyz" val outmsg : byref<string> -> unit 
+6
source

Out parameters look like ref - you need to use := like this (taken from MSDN docs)

 open System.Runtime.InteropServices;; type dummy() = member this.MyMethod([<param: Out>] x : ref<int>) = x := 10 ;; 
0
source

All Articles