开发者

A save function in F# that does not want to run

I have borrowed the following save function to save values of any type to a given file (cheers to John Harrop, writer of F# for scientists).

    open System.IO
    open System.Runtime.Serialization.Formatters.Binary

    let save filename x =
       use stream =
         new FileStream(filename, FileMode.C开发者_StackOverflowreate)
       (new BinaryFormatter()).Serialize(stream, x);;

But F# is telling me that there is no body for the "use" part of the function. I seems to not like the final line but the intellisense is not giving me an error message when I hover.

Do I need to declare another namespace?

Can anyone advise? Very grateful for any help.


Works on my machine! :-) If you're typing this directly into FSI try putting it in a script file and using 'Send to Interactive'. If you're not, remove ;; on the last line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜