到目前为止,这就是我所拥有的。
let Swap (left : int , right : int ) = (right, left)
let mutable x = 5
let mutable y = 10
let (newX, newY) = Swap(x, y) //<--this works
//none of these seem to work
//x, y <- Swap(x, y)
//(x, y) <- Swap(x, y)
//(x, y) <- Swap(x, y)
//do (x, y) = Swap(x, y)
//let (x, y) = Swap(x, y)
//do (x, y) <- Swap(x, y)
//let (x, y) <- Swap(x, y)
最佳答案
你不能没有语法可以通过一次分配来更新“多个可变变量”。当然可以
let newX, newY = Swap(x,y)
x <- newX
y <- newY
关于f# - 如何返回多个值并将其分配给可变变量?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/946977/