i have got several times , trying to implement different functions, the message you see as title. I would like to know if anyone can tell me the general meaning (and reason) of this error message. As i mentioned before, i have got the problem several times and manage to fix it, but still didnt get the exact reason, so i will not post any specific code.
Thank you in advance
The most common case when you may get this error is when you write
letbinding that is not followed by an expression that calculates the result. In F#, everything is an expression that returns some result, so if you writelet a = 10it is generally not a valid expression. To make it valid, you need to return something:The only exception where you can write just
let a = 10is a global scope of an F# source file – for example, inside a module declaration or in an F# script file. (This is why the declaration offooabove is valid).It is difficult to give any advice without seeing your code, but you probably have a
letdeclaration that is not followed by an F# expression.Out of curiosity, the following example shows that
letcan really be used inside an expression (where it must return some meaningful result):