The VS2010 Beta 2 F# compiler always complains about my usage of the when keyword, even when using copy-pasted code which is supposed to work, such as either of these snippets. For instance, this is the error I get when trying to execute a very trivial expression:
"Error FS0010: Unexpected keyword 'when' in expression. Expected '->' or other token. "
[for i in 1..50 when i < 10 -> i]
---------------^^^^
You want
[for i in 1..50 do
if i < 10 then
yield i]
The 'short' syntax with 'when' was removed a while back. See
http://blogs.msdn.com/dsyme/archive/2008/08/29/detailed-release-notes-for-the-f-september-2008-ctp-release.aspx
and look for "compact sequence expressions" in that document.
You should use the yield keyword now. Like that:
[for i in 1 .. 50 do if i < 10 then yield i]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With