Indentation as Program scope in F#

C# uses the flower bracket “{” and “}” to identify the block or scope of the function or program . F# is quite different in the sense that it uses the indentation or tab to identify the program scope or blocks.

Below is a code snippet demonstrating the indentation used for a program in F#

open System
[<EntryPoint>]
let main argv =
    let Variable1  = "developerpublish - F# Tips & Tricks"
    Console.WriteLine(Variable1)
    let retval = Console.ReadLine()
    0 

If there is an issue with the indentation , you will be prompted with the following error messages . To resolve the issue , we can verify the indentation of the program and fix it.

Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the ‘let’ keyword”

Unexpected identifier in binding. Expected incomplete structured construct at or before this point or other token.

image

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the error message “FileOpenAccessDenied – You do not have permissions to open this file...
  • .NET
  • December 3, 2024
You might have had a situation where your code once worked fine in ASP.NET application but now throws the below...
  • .NET
  • December 3, 2024
Role based security needs authenticated information about the user in order to make some decisions about whether the user is...
  • .NET
  • December 3, 2024