Type Inference and Lambda Expressions
At a higher level, lambda expressions fully support local type inference so that the Visual Basic compiler can decide for you the appropriate data type. For lambdas, there is something more to say. Basically type inference is determined on how you write your code. For example, let’s recall the first lambda expression at the beginning of this section:
Dim f As Func(Of Double, Double, Double) = Function(x, y) x * y
In the preceding code, local type inference affects both arguments and the result of the Function statement; the compiler can infer Double to the x and y parameters and therefore can determine Double as the result type; this is possible only because we explicitly provided types in the delegate declaration, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access