Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent in F# of the C# default keyword?

I'm looking for the equivalent of C# default keyword, e.g:

public T GetNext() {     T temp = default(T);             ... 

Thanks

like image 854
Stringer Avatar asked Feb 11 '10 17:02

Stringer


People also ask

What is degrees C equal to in F?

Convert celsius to fahrenheit 1 Celsius is equal to 33.8 Fahrenheit.

How do you convert C to F easily?

If you find yourself needing to quickly convert Celsius to Fahrenheit, here is a simple trick you can use: multiply the temperature in degrees Celsius by 2, and then add 30 to get the (estimated) temperature in degrees Fahrenheit.


1 Answers

I found this in a blog: "What does this C# code look like in F#? (part one: expressions and statements)"

C# has an operator called "default" that returns the zero-initialization value of a given type:

default(int)  

It has limited utility; most commonly you may use default(T) in a generic. F# has a similar construct as a library function:

Unchecked.defaultof<int> 
like image 87
blu Avatar answered Oct 08 '22 15:10

blu