How do you return multiple values and assign them to mutable variables?

后端 未结 3 1313
谎友^
谎友^ 2021-02-20 17:42

This is what I have so far.

let Swap (left : int , right : int ) = (right, left)

let mutable x = 5
let mutable y = 10

let (newX, newY) = Swap(x, y) //<--thi         


        
3条回答
  •  没有蜡笔的小新
    2021-02-20 18:28

    You can't; there's no syntax to update 'more than one mutable variable' with a single assignment. Of course you can do

    let newX, newY = Swap(x,y)
    x <- newX
    y <- newY
    

提交回复
热议问题