Cloud Training (Online)




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

Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.