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 “WorkbookNotSupported – The file you selected cannot be opened because it...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SpecifiedRangeNotFound – The requested range does not exist in the sheet.”...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SheetRangeMismatch – The sheet provided as the sheet argument is not...
  • .NET
  • December 17, 2022