9
Suppose I create a closure over a resource such as a StreamWriter:
let currentdir = Directory.GetCurrentDirectory()
let testfile = sprintf "%s\\%s" currentdir "closuretest.txt"
let getwriter() =
let writer = new StreamWriter(testfile, false)
(fun() -> writer.Write "test")
Is there a way to close the StreamWriter when I'm done with the closure? Or do I need to replace the closure with a wrapper object that has a Write() method and a Dispose() method? (This is of course a trivialized example.) Thanks all.