I have a usecase where there are two arrays : one is empty and second one has some values
Array1 : {"",""},
Array2 : {1:1,2:2}
After removing null or empty values from Array1 using filter function filter(a!isNotNullorEmpty,Array1), I have got empty array which is of List of Varient type
Now I want to apply difference function difference(Array1,Array2)
Since both are different data types, im being thrown error as invalid types.
If I have any values in Array1 like {1:1}, it would be of type List of Dictionary, but now here it is List of Varient since nothing there in the Array.
How can I perform difference function operation now? Is there any workaround to convert list of varient to list of dictionary ?
Discussion posts and replies are publicly visible
First of all, difference function is to return the values which is present in array 1 and not in array 2. Since first array is empty no need to call difference function itself. So do null check and if both array 1 and array 2 have values call difference function else return array 1.
thats just a usecase not the original one. You cannot know its type and value in runtime as I have given it as Anytype.
we can always do null check for the arrays before using the difference function as the null check doesn't bother type of a variable.