functions in F# .. why is it not compiling

Posted by Tanmoy on Stack Overflow See other posts from Stack Overflow or by Tanmoy
Published on 2011-01-13T05:44:47Z Indexed on 2011/01/13 5:53 UTC
Read the original article Hit count: 235

Filed under:

Hi, I have written two versions of code. The first one works as expected and print "Hi". the second one gives me error that "block following this let is unfinished"

1st version

#light 

let samplefn() =
            let z = 2
            let z = z * 2
            printfn "hi"

samplefn()

2nd version

#light 

let samplefn() =
            let z = 2
            let z = z * 2           

samplefn()

Only difference is the printfn is absent in the second version. I am using Visual Studio 2010 as my IDE. I am very new to F# but this error seems very strange to me. I guess I am missing some very important concept. Please explain.

Edit: Also if I do it outside the function I get error even with the first version of code.

#light
let z = 2
let z = z * 2
printfn "Error: Duplicate definition of value z"

© Stack Overflow or respective owner

Related posts about F#