Explaining type inference

Type inference means that the compiler will automatically deduce the type of an expression used in the code, based on the information provided from the programmer about the context of the expression. Type inference analyses the code, as you have seen in the preceding section, to determine types that are often obvious to the programmer. This spares the programmer from having to explicitly define the types of every single variable. It's not always needed to have the types defined to be able to understand the code, as seen in the preceding section for simple assignments of integers and floats. Type inference will make the code easier to write, and as a consequence, easier to read, leaving a lot of ceremony where it belongs. ...

Get F# for Quantitative Finance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.