F# Recipe #2 – The type int is not compatible with type unit

Problem

When writing your first F# program , you get the following error “The type int is not compatible with type unit”. You need to fix this.

image

Solution

The type unit is F#’s version of void. This indicates that the compiler was expected an return value of int but there is no return value.

This can be fixed by adding 0 to the end to return 0 as shown in the screenshot below.

image

Share:

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
C# uses the flower bracket “{” and “}” to identify the block or scope of the function or program ....
  • .NET
  • December 3, 2024