gpt4 book ai didi

f# - 如何设置 [] 参数?

转载 作者:行者123 更新时间:2023-12-05 00:36:43 28 4
gpt4 key购买 nike

我正在使用参数:[<Out>] message : string
但是当我尝试设置它时:消息 <-“没有关于起始位置的数字”

我收到错误,因为消息不可变。如何提出论点?

最佳答案

公开类型为 byref<string> 的方法参数和属性 [<Out>]并使用带有地址运算符 & 的可变值作为参数:

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

关于f# - 如何设置 [<Out>] 参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7874087/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com