I believe the problem here is what you want the <- to do is just not possible. It's designed to update one mutable variable/member at a time, not tuples of them. There's fst and snd functions that can be used to pull tuples apart, I think using them and spreading the operation over two line is your best bet.

1
2
3
4
5
6
7
#light
let someFunc() =
    let mutable x = 0
    let mutable y = 0
    let t = (1,2)
    x <- fst t
    y <- snd t
By on 7/26/2007 12:43 AM ()

That's perfectly fine with me. Thanks.

DC

By on 7/26/2007 6:13 AM ()

If you do these assignments within a function, you need not care about using mutable variables and could use the following instead...

(Note that in the global scope this would raise an error because of a duplicate definition)

1
2
3
4
5
6
7
8
9
10
11
12
 

#light

let tuple a b = (a, b)
let _ =
    let a, b = tuple 1 2
    //...
    let a, b = tuple 6 9
    print_any a
    print_any b
By on 7/26/2007 9:56 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper