Google News
logo
F# - Interview Questions
What is the unit type in F#?
The unit type is a type which indicates the absence of specific value. The unit type has only a single value. This value acts as a placeholder when no other value exist.
 
Example :
let function1 x y = x + y                 
  
function1 10 20      // this line results a compiler warning  
      
// changing the code to the following and eliminates the warning  
let result = function1 10 20  
  
// Use this if you are calling the function and don't want the return value  
function1 10 20 |> ignore 
Advertisement