Skip to content

Further explanation of v5 validation example #1419

Closed Answered by louthy
CoenraadS asked this question in Q&A
Discussion options

You must be logged in to vote

Could someone please breakdown the fun<int, string, CVV>((code, _) => new CVV(code)) line?

You can also write it like this:

fun((int code, string _) => new CVV(code))

Which might be a bit clearer. Essentially, we're forcing C#'s type system to infer the lambda. The lambda needs to be coerced into being a Func<int, string, CVV>. The fun function does that.

It's the equivalent of:

new Func<int, string, CVV>((code, _) => new CVV(code))

My current understanding:
A function is made for currying

Correct

the first parameter will be provided by ValidateInt(cvv)

Correct

the second by ValidateLength.

Correct

But I don't understand the third one.

The third parameter is the return-type. The C…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@CoenraadS
Comment options

@louthy
Comment options

Answer selected by CoenraadS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants