Working on a program that needs a mutable set. When trying to put the set in a closure I get an error:
let mutable donefiles : Set<FileRecord> = Set.empty
let filestodo = Set.difference parms.FileSpecs donefiles
let errorFile (file: FileRecord) =
donefiles <- Set.add file donefiles
Error 40 The mutable variable 'donefiles' is used in an invalid way. Mutable variables cannot be captured by closures. Consider eliminating this use of mutation or using a heap-allocated mutable reference cell via 'ref' and '!'.
Trying to convert "donefiles" into a ref, but can't seem to get the syntax right. Tried the obvious (to me) first:
let donefiles : Set<FileRecord> = ref Set.empty
but:
Error 40 This expression was expected to have type Set but here has type 'a ref
What is the syntax I should use in this case?
HashSet<FileRecord>? - Lee.ExceptWithto remove a collections of items from aHashSet<T>. - Lee