F# confusing output -


I'm starting an F # I have gone this code:

  let printMsg () = Msg msg = "Important" printfn "% s" msg msg innMsgChange () = msg msg = "very important" printfn "% s" msg printfn "% s" msginMsgChange () printfn "% s" msg print message ( )   

I expected that the text sequence would be in this sequence:

important, very important, important, important or

Important, very important, very important, important

but I found this

important, important, very important, important

It seems that this code of execution order Do not follow. Why is it, I'm missing something?

Firstly, tell change internal messages Promises: It creates a new variable called msg (which is completely unrelated to the external variable which is also called msg value) "very important "And then prints it, in short this string is printed" very important "and that's it.

In which order is the code executed?

  • This variable has been printed.
  • msg
  • variable msg < / Li>
  • is printed again
  • InMark's Change () to

    said Goes 5.1. Inner Variable msg is set to "very important" Let's look at it to distract innerMsg .

    5.2. innerMsg has been printed.

  • msg (which is still the "important" value because it is completely

  • Comments

    Popular posts from this blog

    mysql - BLOB/TEXT column 'value' used in key specification without a key length -

    c# - Using Vici cool Storage with monodroid -

    python - referencing a variable in another function? -