我需要创建一个可变的 option<T>
输入 F#。我试过写作
let x = ref None
然后写
x := Some(z)
但它不起作用。帮助!
最佳答案
您需要明确声明类型以避免 "the Value Restriction" (或见 "Automatic Generalization" on msdn):
let x : Ref<int option> = ref None
x := Some 4
关于f# - 如何创建 F# 可变选项类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2385952/