Tip:
Highlight text to annotate it
X
Try an initial vote. Initial vote. A little bit all over the
map. So this is a good one to talk about. This one is tricky.
This one could plausibly have more than one right answer. Okay.
Second vote. Second vote. Second vote. I wouldn't say this is
universal agreement or anything. That's okay though. This is a
hard question and there is ... It's kind of a matter of opinion
which of these you think could be used. I didn't actually show
an example of using a function as the argument of validation but
you can actually do this. You can do it in cases where you want
to be able to validate an object that's coming in. You can write
a function inline that is actually going to be handed a copy of
the object at validation time. So just like a block, you can
actually pass a block to the validation callbacks instead of
defining a separate function. In that respect, you could say
that higher order functions play a role in validation but you
don't have to use them. You could also do the simple thing we
did in my example which is just write a function and pass the
name of the function. That uses metaprogramming in the sense
that you've got to be able to turn the function name into a
function reference at runtime and call it. So metaprogramming
clearly plays a role. Closures and higher order functions tend
to sort of travel in a herd. They travel together. So in
examples where you decide to pass a function directly to the
validator, you could say that that's a use of higher order
functions and, therefore, of the closures that travel with
higher order functions but you don't always have to do that. So
technically, the right answer is all three of these contribute
but I feel a little bad putting the question in front of you
because I haven't really shown you an example that uses higher
order functions in validations. So in this case, you would have
said that the ... If you said basically C is a candidate.
Anything that include C is correct and if you said all three,
you're also correct. But I will show an example later on if you
guys want of using an actual higher order function of
validation.