I am writing a function that takes a multi-line string through a StringReader and returns each line as an item of a seq
let symbolSeq = seq {
let mutable line = reader.ReadLine()
while !line <> null do
yield line
line <- reader.ReadLine()
}
I am getting a
This expression was expected to have type 'a ref but here has type string
on while !--->line<--- <> null do
When I get rid of the ! in front of line I get a
The mutable variable 'line' 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 '!'.
Why ?