C#, wat?

I'm trying to translate and edit a C# project to C++, but I found myself in front of these lines:

1
2
3
4
5
6
if (j.Count(x => x != null) >= 2)
{
    y.Clear();
    foreach (Color c in j.Where(x => x != null))
        y.Add(c);
}


Consider them valid variables and everything...
What is x => x != null supposed to do?
Last edited on
Don't know C#, but x => x != null is pretty obviously a lambda that returns 1 on references that are not null. Thus j.Count(x => x != null) is the number of objects in j that are not null and foreach (Color c in j.Where(x => x != null)) iterates over all colors in j, which are not null.
Last edited on
Ok, then, I was guessing that but wasn't sure about it, I've never seen that in C++ and I was like... "What?"

Thanks!
Topic archived. No new replies allowed.