WebGL FindAll predicate

Hi!

I have List object, with structure elements.
I want to get subset from this list with some condition.

This code works correctly on any target (except WebGL).

subset = list.FindAll(p => (condition));

With WebGL there is no exceptions or errors. There is the wrong result - I get elements, which are not corresponding to condition.

If I use this code, it all ok on any target (include WebGL).

foreach (StructureType p in list) {
    if (condition) {
        subset.Add(p);
    }
}

So, what’s wrong with FindAll?

Thanks!

Could you provide a bit more code? For example - what type of objects are stored in your list? and what is your predicate code?

I tested with this code:

public class Finder : MonoBehaviour
{
    private List<int> integers;

    void Awake ()
    {
        // initialize with some integers.
        integers = new List<int>(Enumerable.Range(0, 100));
    }

    void Start()
    {
        // get a filtered list.
        var newList = integers.FindAll(i => i % 2 == 0 && i % 7 == 1);

        // convert to a string.
        var str = string.Join(",", newList.Select(i => i.ToString()).ToArray());

        Debug.Log ("Result: " + str);
    }
}

In the editor & the browser, getting the same results printed:
Result: 8,22,36,50,64,78,92

Please provide more information so we can see where the issue is :slight_smile: