Okay, so let's practice predicates slash lambdas once again with some other examples.
So we have this find all.
But then there is another very cool method that is called any.
And the.
Any method uses a lambda to test each number in the list and see if it has a certain number in it.
Okay, so let's use our list from earlier.
We have this list of ten, 15, three and so forth.
And now what we can do is we can go ahead and say numbers dot any.
So you can see here there are two different overloads.
So overloads are two different well methods with the same name but that have different amount of parameters
or different parameters altogether.
And you can see that this one here of this, any method that requires a predicate.
And you can see here a predicate is a function to test each element for a condition.
Okay.
So how can we do that here.
Well we can go ahead and do the same thing as we've done before.
We can just say is there any x that is greater than something.
So x becomes x greater than zero.
So this here now let's say we want to see if there is a number above 20.
So we could go ahead and say like so.
So now this will return a bool.
So it will return whether it's true or not.
Is there a number that is greater than 20.
So what we can do is we can store the result like so where we say bool has large number and we're going
to just use this numbers dot any.
And here we're passing a lambda expression which can be used as a predicate okay.
So not all lambda expressions are predicates but predicates hold lambda expressions or hold methods
okay.
So now what we can do is let's say if has large number we're just going to write onto the console.
There are large numbers in the numbers list okay.
And else you're going to say see you know large numbers in the list okay.
So let's run this and see if we have any large numbers.
And it says there are large numbers in the numbers list.
That is because we said a large number is anything above 20.
So if we said large number is anything above 30 and we run it again, we will probably not get a true
value.
So no large numbers in the list.
That's because we don't have a 30 or higher inside of our numbers list, or actually over 30, not 30
or higher, but 31 and higher.
All right.
So see you in the next video.